Error 404 blog/page/2/

时间:2018-08-11 作者:Arek

你好,我有问题。

我无法查看/博客/页面/2/我单击“\\u posts\\u link”,错误404显示我

博客页面->主页。php

                <?php 
                $paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
                $args = array(\'posts_per_page\' => 5, \'paged\' => $currentPage);
                query_posts($args);
                if( have_posts() ): $i = 0;

                    while( have_posts() ): the_post(); ?>
<小时>
                                <?php $i++; endwhile; ?>
                                <ul class="uk-pagination uk-background-primary uk-light">
                                    <li><?php next_posts_link(\'<span class="uk-margin-small-right" uk-pagination-previous></span> Stare Posty\'); ?></li>
                                    <li class="uk-margin-auto-left"><?php previous_posts_link(\'Nowe posty <span class="uk-margin-small-left" uk-pagination-next>\'); ?></li>
                                </ul>

                                <?php endif;
                                    wp_reset_query();
                                ?>      

2 个回复
SO网友:WPZA

我想你不需要以分类法为目标。您可以使用以下代码:

function query_change_function( $query ) {
     $query->set( \'posts_per_page\', 5 );
}
add_action(\'pre_get_posts\', \'query_change_function\');
你应该把$query->set( \'posts_per_page\', 5 ); 周围有if ( ! is_admin() && is_home() ) {//the $query->set code} 为了避免到处都换成5个帖子。

SO网友:Max

用于分页

<?php
$paged = ( get_query_var( \'page\' ) ) ? absint( get_query_var( \'page\' ) ) : 1;
$content_args=array(
         \'post_type\' => \'post\',
         \'orderby\' => \'meta_value_num\',
         \'paged\' => $paged,
         \'posts_per_page\' => \'5\',
     );
    $wp_query = new WP_Query($content_args);
    while ($wp_query->have_posts()): $wp_query->the_post();?>

    //content here

   <?php endwhile;?>
分页

<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
    \'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) 
),
    \'format\' => \'?paged=%#%\',
    \'current\' => max( 1, get_query_var(\'paged\') ),
    \'total\' => $wp_query->max_num_pages
) );?>

结束

相关推荐

如何在QUERY_POSTS中的自定义字段上放置orderby

我在我的query\\u帖子中有以下查询,希望向其中添加order by。Order by将位于另一个自定义字段上,并按desc Order排序。这是我现有的查询。//show all active posts for this taxonomy query_posts( array( \'post_type\' => APP_POST_TYPE, \'post_status\' => \'publish\', APP_CUSTOM_TAX