Php wordpress分页url第一页

Php wordpress分页url第一页,php,wordpress,Php,Wordpress,我正在我的网站上使用paginate_链接 当我点击第二个url时,我的网址是mywebsite.com/page/2。 然后我将页码设为第1页,网站url显示mywebsite.com/page/1。 我想删除主页首页上的/page/1 本期仅主页。分类页工作正常 例如: 有人能帮我吗 paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) )

我正在我的网站上使用
paginate_链接

当我点击第二个url时,我的网址是mywebsite.com/page/2。 然后我将页码设为第1页,网站url显示mywebsite.com/page/1。 我想删除主页首页上的/page/1

本期仅主页。分类页工作正常

例如:

有人能帮我吗

paginate_links( array(
        'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
        'format' => '/page/%#%',
        'current' => max( 1, get_query_var('paged') ),
        'total' => $wp_query->max_num_pages,
        'prev_next' => true,
        'prev_text'    => __('Prev Page'),
        'next_text'    => __('Next Page'),
        'type'  => 'array'
    ) );

如果yoursite.com/page/1和yoursite.com相同,为什么不使用jquery更改分页链接的href属性

$(".pagination a:first").attr("href", "http://example.com/");
这段代码只是更改分页的第一个链接的url

编辑:这将更改站点的上一个链接的href属性。若用户在第3页上,或者其他什么页面上,那个就不好了

试试这个:

if($('.pagination a:first').attr('href') === "http://example.com/page/1") {
    // this is page 2.
    $(".pagination a:first").attr("href", "http://example.com/");
}
    $(".pagination a:nth-child(2)").attr("href", "http://example.com/");

有一个过滤器可以满足这种需要

add_filter( 'paginate_links', function($link){

    //Remove link page/1/ from the first element and prev element
    
    if(is_paged()){
        $link= str_replace('page/1/', '', $link);
    }

    return $link;
} );

是的,我知道它也能做到。htaccess文件。但我想知道它在category.php上工作,为什么不在主页上工作。谢谢你的回答,你也可以用。它会自动将
yoursite.com/page/1
转换为
yoursite.com