【问题标题】:wordpress custom post type pagination 404 page 2 errorwordpress自定义帖子类型分页404第2页错误
【发布时间】:2021-01-07 01:17:05
【问题描述】:

在我的 Wordpress 自定义主题中,在加载上述页面时出现 404 错误的分页 1。我检查了永久链接和其他内容,但没有成功。

请帮我摆脱。

这是我的代码。

//Loop
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

                 $args = array(
                     'orderby' => 'date',
                     'post_type' => 'jobs',
                     'posts_per_page' => 1,
                     'paged' => 'paged'
                 );
                 $the_query = new WP_Query( $args );

//Pagination
$total = $the_query->max_num_pages;
$big = 999999999; // need an unlikely integer
if( $total > 1 )  {
 if( !$current_page = get_query_var('paged') )
     $current_page = 1;
 if( get_option('permalink_structure') ) {
     $format = 'page/%#%/';
 } else {
     $format = '&paged=%#%';
 }
 echo paginate_links(array(
     'base'          => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
     'format'        => $format,
     'current'       => max( 1, get_query_var('paged') ),
     'total'         => $total,
     'mid_size'      => 3,
 ) );
}

【问题讨论】:

    标签: wordpress pagination custom-post-type


    【解决方案1】:

    请将此代码添加到您的主题文件中的function.php文件中

    flush_rewrite_rules( false );
    

    【讨论】:

    • 问题依然存在。
    • 请根据wordpress中的模板层次结构创建单独的模板来显示页面。
    猜你喜欢
    • 2014-07-12
    • 2015-06-07
    • 2020-03-22
    • 2014-03-24
    • 2017-09-22
    • 2018-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多