简体   繁体   中英

Pagination is not working in static blog page in Wordpress

I am using the default theme in 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.

The URL shows that it moved to page two, but it is showing the same page (ie not the next x number of posts).

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. 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); 
             } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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