简体   繁体   English

分页在Wordpress中的静态博客页面中不起作用

[英]Pagination is not working in static blog page in Wordpress

I am using the default theme in Wordpress. 我在Wordpress中使用默认主题。 When I set my blog page to static and select my Blog List template as the page template, it will not navigate to other pages using the paginated links. 当我将博客页面设置为静态并选择我的Blog List模板作为页面模板时,它将不会使用分页链接导航到其他页面。

The URL shows that it moved to page two, but it is showing the same page (ie not the next x number of posts). 该URL显示它已移至第二页,但它显示的是同一页面(即不是下一个x个帖子)。

I have Googled but I did not find a satisfactory answer. 我用谷歌搜索,但我找不到满意的答案。 Some posts suggest trying some code. 一些帖子建议尝试一些代码。 I tried what they suggested but nothing works for me, 我尝试了他们的建议,但没有任何对我有用,

My blog list template code is below: 我的博客列表模板代码如下:

<?php
/*
Template Name: Blog List
*/
?>
<?php get_header(); ?>

<div id="container">
    <div class="main<?php if ( is_active_sidebar( 'home-sidebar-small' ) ) : ?> small-sidebar<?php endif; ?>">

<?php if ( is_active_sidebar( 'home-sidebar-small' ) ) : ?>
<div class="sidebar-small">
<?php dynamic_sidebar( 'home-sidebar-small' ); ?>
</div><!-- Sidebar Small -->
<?php endif; ?>

        <div class="content">
            <div class="warp">

            <?php if(bdayh_get_option('article_crumbs') == 1) { ?>
                <div class="pp-breadcrumbs bottom10">
                    <?php bd_breadcrumbs() ?>
                </div><!--//end breadcrumbs-->
                <hr class="bottom15">
            <?php } ?>
<img alt="Amir Anzur" src="http://amiranzur.com/images/Capture.PNG"/>
<br/><br/><br/>

            <?php 
if(bdayh_get_option('disable_custom_template_blog') == 1) { 
                query_posts(
                    array(

'cat' => bdayh_get_option('custom_template_blog_category'), // Enter your ID number  
                                   'paged' => get_query_var('paged'),
'post_type' => 'post',


                    )

                );



             } else {  
                          query_posts('posts_per_page=3&paged=' . $paged); 
             } 
                //rewind_posts();
                get_template_part( 'loop-archive', 'category' );    
                if ($wp_query->max_num_pages > 1) bd_pagenavi();

             if (comments_open() && !post_password_required()) {
             comments_template('', true); 
             } 


?>

            </div>
        </div><!-- content -->

    </div>
</div>
<!-- container -->
    <div id="sidebar">
        <?php if  (function_exists('dynamic_sidebar') && dynamic_sidebar('Page Sidebar')){ }else { ?>
            <?php get_sidebar(); ?>
        <?php } ?>
    </div><!-- sidebar /-->

<?php get_footer(); ?

> >

You use the variable $paged here yet I don't see where it's defined. 你在这里使用变量$ paged但我没有看到它的定义。 Try changing this: 尝试改变这个:

if ( get_query_var( 'paged' ) ) {
    $paged = get_query_var( 'paged' );
} elseif ( get_query_var( 'page' ) ) {
    $paged = get_query_var( 'page' );
} else {
    $paged = 1;
}

if(bdayh_get_option('disable_custom_template_blog') == 1) { 
                query_posts(
                    array(

'cat' => bdayh_get_option('custom_template_blog_category'), // Enter your ID number  
                                   'paged' => $paged,
'post_type' => 'post',


                    )

                );



             } else {  
                          query_posts('posts_per_page=3&paged=' . $paged); 
             } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM