【问题标题】:Custom pagination - arrows not working自定义分页 - 箭头不起作用
【发布时间】:2012-07-19 14:39:38
【问题描述】:

我有一个奇怪的问题,即为下一页和上一页生成的箭头不起作用。我似乎无法修复它。 html 似乎很好,数字工作,但是当点击什么都没有发生:http://sketchbookmagazine.com/category/fashion/

分页码:

function pagination($prev = '«', $next = '»') {
    global $wp_query, $wp_rewrite;
    $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
    $pagination = array(
        'base' => @add_query_arg('paged','%#%'),
        'format' => '',
        'total' => $wp_query->max_num_pages,
        'current' => $current,
        'prev_text' => __($prev),
        'next_text' => __($next),
        'type' => 'plain'
);
    if( $wp_rewrite->using_permalinks() )
        $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );

    if( !empty($wp_query->query_vars['s']) )
        $pagination['add_args'] = array( 's' => get_query_var( 's' ) );

    echo paginate_links( $pagination );
};

html:

<div class="pagination"><?php pagination('«','»'); ?></div>

非常感谢任何帮助!

【问题讨论】:

标签: php wordpress pagination


【解决方案1】:

我从未见过这种结构:

$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;

尝试将其更改为:

$current = $wp_query->query_vars['paged'] > 1 ? $wp_query->query_vars['paged'] : 1;

【讨论】:

猜你喜欢
  • 2019-02-03
  • 1970-01-01
  • 1970-01-01
  • 2011-08-13
  • 2019-12-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-02
相关资源
最近更新 更多