admin管理员组

文章数量:1336106

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 );

本文标签: How to search for many post types