wp query - WP_Query author parameter not working

As per doumentation Author Parameters #Author Parametersauthor (int) – use author id.author_name (string) – use ‘user_n

As per doumentation

Author Parameters #Author Parameters

  1. author (int) – use author id.
  2. author_name (string) – use ‘user_nicename‘ – NOT name.
  3. author__in (array) – use author id (available since version 3.7).
  4. author__not_in (array) – use author id (available since version 3.7).

Can they all work together?

If I keep author__not_in, first 3 does not work? author__not_in is an empty array

As per doumentation

Author Parameters #Author Parameters

  1. author (int) – use author id.
  2. author_name (string) – use ‘user_nicename‘ – NOT name.
  3. author__in (array) – use author id (available since version 3.7).
  4. author__not_in (array) – use author id (available since version 3.7).

Can they all work together?

If I keep author__not_in, first 3 does not work? author__not_in is an empty array

Share Improve this question asked Apr 27, 2019 at 20:37 user145078user145078 1
  • Can you give a realistic sample of what posts you would be looking for then, exactly? Having author__not_in set for what would you need to use the 3 others then? – norman.lol Commented Apr 27, 2019 at 22:04
Add a comment  | 

1 Answer 1

Reset to default 1

First, the author parameter is parsed and appended to the author__in and author__not_in query parameters.

Then author__in or author__not_in array is processed. These can be arrays created from author parameter or arrays passed as query parameteres author__in / author__not_in or created from a mergion author parameter with author__in / author__not_in parameters.

Parameters author__in and author__not_in are mutually exclusive, so you can use only one of them. If both are given, then author__not_in will be used.

Finally, the author_name parameter is processed and added to thewhere clause. Although theoretically it can be used with any of the other parameters, the effect will be the same as if only author_name was used.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745545403a4632314.html

相关推荐

  • wp query - WP_Query author parameter not working

    As per doumentation Author Parameters #Author Parametersauthor (int) – use author id.author_name (string) – use ‘user_n

    23小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信