Free Photos
WordPress Themes

Integrating Custom Post Types in the WordPress Search

<?php function ah_searchAll( $query ) { if ( $query->is_search ) { $query->set( 'post_type', array( 'site','plugin', 'theme','person' )); } // Custom Post Types noch anpassen return $query; } add_filter( 'the_search_query', 'ah_searchAll' );
To have Custom Post Types, which are available since WordPress 3.0, be displayed in the results of the WordPress search, this code is required:

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.