【问题标题】:Pagination is not working in static blog page in Wordpress分页在 Wordpress 的静态博客页面中不起作用
【发布时间】:2014-03-15 04:01:57
【问题描述】:

我在 Wordpress 中使用默认主题。当我将我的博客页面设置为静态并选择我的Blog List 模板作为页面模板时,它不会使用分页链接导航到其他页面。

URL 显示它已移至第二页,但显示的是同一页面(即不是下 x 个帖子)。

我已经用 Google 搜索过,但没有找到满意的答案。一些帖子建议尝试一些代码。我尝试了他们的建议,但对我没有任何效果,

我的博客列表模板代码如下:

<?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(); ?

>

【问题讨论】:

    标签: php css wordpress pagination


    【解决方案1】:

    您在这里使用了变量 $paged,但我看不到它的定义位置。尝试改变这个:

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

    【讨论】:

    • 我厌倦了这个但仍然出现相同的页面
    • 我已经修改了答案
    • 可能是在function.php或其他文件中定义的,因为我只显示特定的模板文件
    • 它对我有用 非常感谢您,先生,您真的很棒,感谢上帝保佑您
    猜你喜欢
    • 1970-01-01
    • 2015-12-19
    • 1970-01-01
    • 2015-07-02
    • 2021-07-06
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 2017-07-26
    相关资源
    最近更新 更多