WordPress类别分页返回404

我知道这可能是一个重复的问题, 但是我在这里找不到的答案没有帮助我, 所以我还是决定问这个问题。

我正在使用自定义帖子类型创建WP模板。我正在使用本教程构建分页https://medium.com/@bikramkc/wordpress-custom-pagination-functions-php-without-a-plugin-961bc4fb930f

我的cpt存档http://angelsports.com.br/custom_post_type/

但是当我尝试转到http://angelsports.com.br/custom_post_type/page/2时, 它将返回404。

这是我正在使用的代码:

// archive.php

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = [
    "post_type" => "clientes", "posts_per_page" => '12', "paged" => $paged
];
query_posts($args);
if (have_posts()) :
    ?>
<ul class="customers-section--list">
    <?php
        while (have_posts()) : the_post(); ?>
[...]
<?php
    if (function_exists('custom_pagination')) {
        custom_pagination($loop->max_num_pages, "", $paged);
    }
endif;
?>
// category.php

<?php

    $currCat = get_category(get_query_var('cat'));
    $cat_name = $currCat->name;
    $cat_id   = get_cat_ID( $cat_name );

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = [
        "post_type" => "clientes", "posts_per_page" => '12', "paged" => $paged, 'category_name' => $cat_name
    ];
    query_posts($args);
    if (have_posts()) :
?>
<ul class="customers-section--list">
    <?php
        while (have_posts()) : the_post();
[...]
<?php
    if (function_exists('custom_pagination')) {
        custom_pagination($loop->max_num_pages, "", $paged);
    }
endif;

自定义帖子类型设置

add_action('init', 'cpt_customers');
function cpt_customers()
{
    $labels = [
        'name' => 'Clientes', 'singular_name' => 'Cliente'
    ];

    $args = [
        'labels' => $labels, 'supports' => ['title', 'editor', 'thumbnail'], 'public' => true, 'menu_icon'   => 'dashicons-groups', 'taxonomies' => ['category'], 'has_archive' => true, ];

    register_post_type('clientes', $args);
}

#1


三用这个

echo paginate_links( array(
    'current' => max( 1, $paged ), 'total'   => $loop->max_num_pages
) );

并且在使用新循环之前你获得了$ paged …变量定义应该低于query_posts

来源:

https://www.srcmini02.com/64232.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37495.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?