【问题标题】:skip the latest wordpress posts in wp_get_archives()跳过 wp_get_archives() 中最新的 wordpress 帖子
【发布时间】:2010-12-12 05:58:20
【问题描述】:

在我的侧边栏中,我显示了最新的 wordpress 帖子列表,如下所示: wp_get_archives('type=postbypost&limit=10');

这还将显示我博客首页上当前可见的帖子的链接。如果这些帖子在主页上可见,那么将它们包含在列表中是没有意义的。

在法典中,我找不到排除首页上帖子的选项。 我该怎么做?

【问题讨论】:

    标签: php wordpress list


    【解决方案1】:

    我认为 wp_get_archives 没有偏移功能。
    http://codex.wordpress.org/Function_Reference/wp_get_archives

    您将不得不改用 get_posts。您可以使用前面提到的offset paramter 或者将其设置为显示 10 random posts

    【讨论】:

      【解决方案2】:

      您也可以使用 WP_Query,如下所示:

      $recent_posts = new WP_Query('showposts=3&offset=3&');
      

      【讨论】:

        【解决方案3】:

        使用'offset'参数,像这样:

        wp_get_archives('type=postbypost&limit=10&offset=0');
        

        当然,您必须将 0 替换为要跳过的所需帖子数。

        【讨论】:

        猜你喜欢
        • 2013-01-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多