Wordpress 每页的帖子数、展示帖子数、帖子数。什么';有什么区别?

Wordpress 每页的帖子数、展示帖子数、帖子数。什么';有什么区别?,wordpress,Wordpress,每次我看到不同的答案。 有谁能给我一个可靠的答案,说明两者的区别吗 查询帖子时,numberposts,showposts,每页帖子 谢谢。他们都一样,做的事情完全一样。但用法略有不同 numberposts、posts\u per\u page和showposts都在中有效numberposts在传递到WP\u查询之前设置为posts\u per\u page。检查源代码 if ( ! empty($r['numberposts']) && empty($r['posts_p

每次我看到不同的答案。 有谁能给我一个可靠的答案,说明两者的区别吗 查询帖子时,
numberposts
showposts
每页帖子


谢谢。

他们都一样,做的事情完全一样。但用法略有不同

  • numberposts
    posts\u per\u page
    showposts
    都在中有效
    numberposts
    在传递到
    WP\u查询之前设置为
    posts\u per\u page
    。检查源代码

    if ( ! empty($r['numberposts']) && empty($r['posts_per_page']) )
        $r['posts_per_page'] = $r['numberposts'];
    
  • 每页的
    posts\u
    showposts
    WP\u查询中均有效,但
    numberposts
    无效。如果使用了
    showposts
    ,则在
    WP\u查询
    类中将其设置为
    posts\u per\u page
    。请参阅源代码

    if ( isset($q['showposts']) && $q['showposts'] ) {
        $q['showposts'] = (int) $q['showposts'];
        $q['posts_per_page'] = $q['showposts'];
    }
    
虽然食品法典委员会称,
showposts
已被折旧,但core中仍然没有折旧通知。然而,它被替换为每页
posts\u

为了回答您的问题,
posts\u per\u page
可能是最好的选择,因为
numberposts
showposts
WP\u查询中被设置为
posts\u per\u page