Custom Search – Small Tweak
-
Our site currently has a search area and we are using facetious search plugin. We also have custom post types (I believe that is the right terminology). When the search is performed it searches the basic pages and one of our custom page types, ‘products’. Now we have another custom page type we need it to search called ‘works’.
Here is the current code:
<?php $customPostType = 'btp_product'; $customPostTypeWork = 'btp_work'; // first query query_posts($query_string.'&post_type='.$customPostType); $customPosts = $wp_query->posts; // second query $postTypes = get_post_types(array( 'public' => true )); unset($postTypes[$customPostType]); $args = array_merge( $wp_query->query_vars, array( 'post_type' => $postTypes, )); query_posts($args); $wp_query->posts = array_merge( $customPosts, $wp_query->posts ); $wp_query->post_count = count($wp_query->posts); ?>
I have added the code:
$customPostTypeWork = 'btp_work';
And if you sub in
$customPostTypeWork
forcustomPostType
on this linequery_posts($query_string.'&post_type='.$customPostType);
then the search will show ‘works’ but not ‘products’. How can I get both of those page types, along with the default, to show up?Thank you in advance!
You can check out the current site at https://www.parts.uic.com.
- The topic ‘Custom Search – Small Tweak’ is closed to new replies.