How to search for many post types?

I actually wanted to reply to another post, unfortunately that is no longer possible.Therefore a short and crisp questi

I actually wanted to reply to another post, unfortunately that is no longer possible.

Therefore a short and crisp question. ;-)

If I want to search in several post types, can I simply work with 'post_type' => 'post' with comma values?

'post_type' => 'post', 'Pages', 'etc ..'

I actually wanted to reply to another post, unfortunately that is no longer possible.

Therefore a short and crisp question. ;-)

If I want to search in several post types, can I simply work with 'post_type' => 'post' with comma values?

'post_type' => 'post', 'Pages', 'etc ..'

Share Improve this question edited Jun 29, 2020 at 20:44 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Jun 28, 2020 at 16:44 Karsten ThiemannKarsten Thiemann 132 bronze badges 1
  • Not Ajax but interesting use of array with inputs to search in several post types: wordpress.stackexchange/questions/286586/… – Jesús Franco Commented Jun 28, 2020 at 20:01
Add a comment  | 

1 Answer 1

Reset to default 3

This is documented here: https://developer.wordpress/reference/classes/wp_query/#post-type-parameters

So to search for several post types you do:

$args = array(
    'post_type' => array( 'post', 'page', 'movie', 'book' )
);
$query = new WP_Query( $args );

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

相关推荐

  • How to search for many post types?

    I actually wanted to reply to another post, unfortunately that is no longer possible.Therefore a short and crisp questi

    17小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信