WP PageNavi无效

时间:2014-04-26 00:28:53

标签: php wordpress plugins wordpress-plugin

我的wordpress主题应该与PageNavi兼容,但是当我安装插件并激活它时,它并没有像它应该的那样工作。

我的博客是新的,有2页的帖子。当我点击第2页时,它只是再次加载主页(第1页)。

这是位于页面上的代码:

<div class="container-fluid">
<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 1;

function filter_where( $where = '' ) {
    $duration = '-' . of_get_option('frontpage_popularity_duration') . ' days';
    $where .= " AND post_date > '" . date('Y-m-d', strtotime($duration)) . "'";
    return $where;
}

if (is_home()) {
    if ('likes' == $popularity = of_get_option('frontpage_popularity')) {
        add_filter('posts_where', 'filter_where');

        $args = array(
            'meta_key' => '_Likes Count',
            'meta_compare' => '>',
            'meta_value' => '0',
            'orderby' => 'meta_value_num',
            'order' => 'DESC',
            'paged' => $paged
        );
        query_posts($args);
    } else if ($popularity == 'repins') {
        add_filter('posts_where', 'filter_where');

        $args = array(
            'meta_key' => '_Repin Count',
            'meta_compare' => '>',
            'meta_value' => '0',
            'orderby' => 'meta_value_num',
            'order' => 'DESC',
            'paged' => $paged
        );
        query_posts($args);
    } else if ($popularity == 'comments') {
        add_filter('posts_where', 'filter_where');

        $args = array(
            'orderby' => 'comment_count',
            'paged' => $paged
        );
        query_posts($args);
    } else {
        $args = array(
            'paged' => $paged
        );
        query_posts($args);
    }
}

get_template_part('index', 'masonry');
get_footer();?>

帖子下面的代码是:

<?php get_sidebar('main'); ?>
<?php if(function_exists('wp_pagenavi')) { ?>
<div id="navigation" class="pagination pagination-centered">
    <?php wp_pagenavi(); ?>
</div>
<?php } else { ?>

<div id="navigation">
    <ul class="pager">
        <li id="navigation-previous"><?php previous_posts_link(__('&laquo; Previous', 'pinclone')) ?></li>
        <li id="navigation-next"><?php next_posts_link(__('Next &raquo;', 'pinclone')) ?></li>
    </ul>
</div>
<?php } ?>

<div id="scrolltotop"><a href="#"><i class="icon-chevron-up"></i><br /><?php _e('Top', 'pinclone'); ?></a></div>

0 个答案:

没有答案