WordPress Pagination与Page 1相同

use*_*432 4 php wordpress pagination wordpress-theming

我正在努力让WordPress分页工作.

我使用了不同的插件,并尝试调整pagination.php函数中的代码无济于事.

无论到目前为止我使用过什么插件或调整,第2页,第3页等都会显示相同的帖子.

这是pagination.php中的代码

<!-- Previous / More Entries -->        
<div class="mdnw_pagination">

<?php if(function_exists('wp_paginate')) :
    wp_paginate();
; else : ?>
<div class="p button"><?php next_posts_link(__('« Previous Posts', 'skeleton')); ?></div>
<div class="m button"><?php previous_posts_link(__('Next Posts »', 'skeleton')); ?></div>
<?php endif; ?>

</div>
<!-- </Previous / More Entries -->
Run Code Online (Sandbox Code Playgroud)

以下是主页的博客模板的代码:

<!-- THE POST QUERY -->
                        <?php 

                    wp_reset_query();

                    global $paged;
                    global $template_file;
                    $cat_string = '';
                    $format = '';

                    if( get_post_custom_values('blog_post_count') ) :  
                        $post_array = get_post_custom_values('blog_post_count');
                        $post_count = join(',', $post_array);
                    else : 
                        $post_count = -1;
                    endif;

                    /* Get Category Filter */
                    if(get_custom_field('blog_category_filter' )) :
                        $cats = get_custom_field( 'blog_category_filter' );
                        foreach ( $cats as $cat ) {
                            $acats[] = $cat;                
                        }
                        $cat_string = join(',', $acats);                    
                    endif;

                    $args=array(
                        'cat'=>$cat_string,            // Query for the cat ID's (because you can't use multiple names or slugs... crazy WP!)
                        'posts_per_page'=>$post_count, // Set a posts per page limit
                        'paged'=>$paged,               // Basic pagination stuff.
                       );

                    query_posts($args); ?>

                    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> 

                        <?php get_template_part( 'includes/format', $format ); ?>

                    <?php endwhile; else: ?>

                        <div class="post">
                              <p><?php _e('Sorry, no posts matched your criteria.', 'skeleton') ?></p>
                        </div><!-- /.post -->

                    <?php endif; ?>  
                    <?php get_template_part( 'includes/element', 'pagination' ); ?>                    
                    <?php wp_reset_query(); ?>                  

                </div>
Run Code Online (Sandbox Code Playgroud)

我应该在两个文件中更改什么才能让它显示除第一页之外的任何其他内容?

我会更改阅读窗格设置,但查询帖子功能使用我不知道的动态值.

如何或我可以改变什么来使它工作?

我尝试了这个页面上的解决方案https://wordpress.stackexchange.com/questions/105977/wordpress-pagination-not-working-always-showing-first-pages-content,但无济于事:

这是我将代码更改为:

<?php 

                    wp_reset_query();

                    global $paged;
                    global $template_file;
                    $cat_string = '';
                    $format = '';

                    if( get_post_custom_values('blog_post_count') ) :  
                        $post_array = get_post_custom_values('blog_post_count');
                        $post_count = join(',', $post_array);
                    else : 
                        $post_count = -1;
                    endif;

                    /* Get Category Filter */
                    if(get_custom_field('blog_category_filter' )) :
                        $cats = get_custom_field( 'blog_category_filter' );
                        foreach ( $cats as $cat ) {
                            $acats[] = $cat;                
                        }
                        $cat_string = join(',', $acats);                    
                    endif;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
                    $args=array(
                        'cat'=>$cat_string,            // Query for the cat ID's (because you can't use multiple names or slugs... crazy WP!)
                        'posts_per_page'=> 9, // Set a posts per page limit
                        'paged'=>$paged,               // Basic pagination stuff.
                       );

                    $your_query = new WP_Query( $args ); ?>

                    <?php if ( $your_query->have_posts() ) : while ( $your_query->have_posts() ) : $your_query->the_post(); ?>  

                        <?php get_template_part( 'includes/format', $format ); ?>

                    <?php endwhile; else: ?>

                        <div class="post">
                              <p><?php _e('Sorry, no posts matched your criteria.', 'skeleton') ?></p>
                        </div><!-- /.post -->

                    <?php endif; ?>  
                    <?php get_template_part( 'includes/element', 'pagination' ); ?>                    
                    <?php wp_reset_query(); ?>  
Run Code Online (Sandbox Code Playgroud)

use*_*432 7

我修好了它.

我在这里找到了解决方法:http: //themeforest.net/forums/thread/pagination-on-wordpress-static-page-set-to-front-page/28120

而不是这样做:

   $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts( array( 'post_type' => 'post', 'paged' => $paged ) );
Run Code Online (Sandbox Code Playgroud)

我这样做了:

if ( get_query_var('paged') ) {

$paged = get_query_var('paged');

} elseif ( get_query_var('page') ) {

$paged = get_query_var('page');

} else {

   $paged = 1;

}

query_posts( array( 'post_type' => 'post', 'paged' => $paged ) );
Run Code Online (Sandbox Code Playgroud)

现在它有效!