wordpress调用文章数量numberposts

在调用文章时,如果不指定numberposts数量,默认为5,如果指定了一定数量,那么就调用指定的条数。如果想要调用所有,那么指定为-1即可。如下:

PHP复制

$relates = get_posts(array(
    \'post_type\' => \'propertyawardwinners\', 
    \'numberposts\' => -1, 
    \'tax_query\' => array(
    array(
        \'taxonomy\' => \'country\',
        \'field\' => \'slug\',
        \'terms\' => array($tax_country),
        \'include_children\' => false
    )
  )
));