douyin9987 2012-01-09 04:20
浏览 53

Wordpress Query_posts只返回6个帖子。 为什么?

I am a plugin developer and I'm using the following function to query particular posts in wordpress in my plugin. The problem is that even when $this->params['num'] is set to something like 12, the query is only returning 6 posts. My Plugin can be found HERE. It is working fine for me and in most cases. But i have got 2 odd support queries from users that in their case it did not work. Is it because of an older wordpress version or because of some conflict with their theme? Here is one conflicting page (he uses WP 3.0.5)

private function lcp_set_categories(){
    if($this->params['name'] != '' && $this->params['id'] == '0'){
        $this->cgid = $this->get_category_id_by_name($this->params['name']);
    }else{
        $this->cgid = $this->params['id'];
    }

    $lcp_category = 'cat=' . $this->cgid;

    //Build the query for get_posts()
    $cgquery = 'cat=' . $this->cgid .
                            '&posts_per_page=' . $this->params['num'] .
                            '&orderby=' . $this->params['orderby'] .
                            '&order=' . $this->params['order'] .
                            '&exclude=' . $this->params['excludeposts'] .
                            '&tag=' . $this->params['tags'] .
                            '&offset=' . $this->params['offset'].
                            '&meta_key=' . $this->params['customfield'].
                            '&meta_value=' . $this->params['customfieldvalue'];

    $this->cgposts = get_posts($cgquery);

}
  • 写回答

2条回答 默认 最新

  • douba6365 2012-01-09 05:08
    关注

    I believe you are calling the function with the wrong parameters. Refer here http://shibashake.com/wordpress-theme/wordpress-query_posts-and-get_posts for a quick explanation, and refer to the Codex for an in-depth explanation.

    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程