function zm_filter_search( $query ) { if ( ! $ query->is_admin && $query->is_search ) { //Add the article type you want to display in the search results $query->set( 'post_type', array( 'post', 'page', 'book' ) ); } return $query; } add_filter( 'pre_get_posts', 'zm_filter_search' );
![weinxin](https://zmingcx.com/wp-content/uploads/2019/08/wx.png)