0
在我的wordpress博客中,我可以按月查看所有的存檔列表。但點擊月份鏈接後,它不會顯示該月的博客文章。它只是刷新頁面。有沒有任何PHP文件添加或功能? 那麼如何在特定月份中點擊存檔列表中的月份鏈接來獲取所有帖子?如何在wordpress中獲取每月的歸檔文章?
EX:當我點擊存檔列表中的'June'鏈接時,它不會在6月份顯示帖子。它只是刷新頁面
在我的wordpress博客中,我可以按月查看所有的存檔列表。但點擊月份鏈接後,它不會顯示該月的博客文章。它只是刷新頁面。有沒有任何PHP文件添加或功能? 那麼如何在特定月份中點擊存檔列表中的月份鏈接來獲取所有帖子?如何在wordpress中獲取每月的歸檔文章?
EX:當我點擊存檔列表中的'June'鏈接時,它不會在6月份顯示帖子。它只是刷新頁面
在wordpress中安裝了默認的Archives Widgets,您只需將該小部件放在側邊欄中您想要顯示存檔帖子的任何位置即可。
register_sidebar(array(
'name' => __('Primary Widget Area', 'twentyten'),
'id' => 'primary-widget-area',
'description' => __('The primary widget area', 'twentyten'),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
));
在您的主題function.php中註冊一個側欄,然後在該側欄中分配該小部件。
這裏是archive.php文件的主題下的代碼
<?php
/**
* The template for displaying Archive pages.
*
* Used to display archive-type pages if nothing more specific matches a query.
* For example, puts together date-based pages if no date.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
get_header(); ?>
<div id="container">
<div id="content" role="main">
<?php
/* Queue the first post, that way we know
* what date we're dealing with (if that is the case).
*
* We reset this later so we can run the loop
* properly with a call to rewind_posts().
*/
if (have_posts())
the_post();
?>
<h1 class="page-title">
<?php if (is_day()) : ?>
<?php printf(__('Daily Archives: <span>%s</span>', 'twentyten'), get_the_date()); ?>
<?php elseif (is_month()) : ?>
<?php printf(__('Monthly Archives: <span>%s</span>', 'twentyten'), get_the_date('F Y')); ?>
<?php elseif (is_year()) : ?>
<?php printf(__('Yearly Archives: <span>%s</span>', 'twentyten'), get_the_date('Y')); ?>
<?php else : ?>
<?php _e('Blog Archives', 'twentyten'); ?>
<?php endif; ?>
</h1>
<?php
/* Since we called the_post() above, we need to
* rewind the loop back to the beginning that way
* we can run the loop properly, in full.
*/
rewind_posts();
/* Run the loop for the archives page to output the posts.
* If you want to overload this in a child theme then include a file
* called loop-archive.php and that will be used instead.
*/
get_template_part('loop', 'archive');
?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
archive.php
在小工具頃它說:「沒有側邊欄定義」,但我做的sidebar.php文件?如何解決它? – Miuranga
我編輯了我的答案plz檢查.. –
這效果很好。但即使將該小部件放在邊欄中,也不會顯示該月下的帖子。它只會刷新不顯示的帖子。 EX:當我點擊存檔列表中的「六月」鏈接時,它不會在六月份顯示帖子。 – Miuranga