dongzhanlu0658 2018-07-19 18:41
浏览 62

Wordpress WP-PageNavi不适用于主页上的特定类别帖子

This is the code I'm using to show recent posts from specific category on the homepage on my Wordpress website. But the issue I'm facing is that WP-pageNavi plugin isn't working properly.

<div class="frontleft">
  <div id="four-columns" class="grid-container" style="display:block;">
    <?php $catquery = new WP_Query( 'cat=3&posts_per_page=24' ); ?>
    <ul class="rig columns-4">
      <?php while($catquery->have_posts()) : $catquery->the_post(); ?>
      <li>
        <a href="<?php the_permalink() ?>">
            <?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
        </a>
        <h3>
            <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
        </h3>
      </li>
      <?php endwhile; ?> 
    </ul>
  </div>
  <div class="navigation">
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
    <?php } ?> 
  </div>
</div>

Note: I'm able to open mywebsite.com/page/2 without having any issue. But the post list is exactly same on each page.

How to fix it?

  • 写回答

1条回答 默认 最新

  • dqpdb82600 2018-07-19 19:53
    关注

    If I were you I would just use different Page Templates for homepage and other pages. It's hard to debug a plugin that we aren't using.

    There is a function in Wordpress is_page() where you can input the name of the page in the para. Throwing that in an if statement is also another way to separate the posts.

    There are a ton of ways to achieve what your looking for without the use of a plugin.

    评论

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应