Support » Fixing WordPress » How to Include Custom Post Types in Search Results and Archives

  • My custom post type is not showing up in my search results or in my archives. I’m not really sure what to do here. For example, when I go to my category ‘Portfolio’, it does not return anything, even though I have have 2 custom posts in that category.

    Anyone know what to do?

    My website is

    Hoping to get this resolved soon.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Ok, I figured out how to include them in the search results. I had forgotten that I had excluded pages from my search results, but I forgot to add in my custom post type for the search results.

    However, my custom post types are still not appearing for my taxonomies. I’m just using the ‘category’ taxonomy for my custom post type, but when I go to the category page for my custom post type, nothing appears. Anyone know what to do here?

    Anyone have any idea what do to?

    Still haven’t found a resolution to this. Any suggestions?

    I’m also interested to find how to search custom post types.

    Does anybody have any solution to this? You can view an example here:

    None of my custom post types show up, even though I have 2 in that category.

    What needs to be done to fix this?

    query_posts( array(‘post_type’ => array(‘apps’,’posts’), ‘cat’ => $cat) );

    Directly above
    if (have_posts ()) :

    This will pull the custom type apps in the category page. I’m sure you can do the same for tags.

    Put that into my code, but still didn’t work. 🙁

    How did you include the custom post types in your searches?

    I placed this code in my functions.php file:

    function filter_search($query) {
        if ($query->is_search) {
    	$query->set('post_type', array('post', 'folio'));
        return $query;
    add_filter('pre_get_posts', 'filter_search');

    This will return results from my posts and from my custom post type called ‘folio’. You should replace that with your custom post type(s) names. Also, this bit of code removes pages from search results, which is generally a good thing. 🙂

    So if I had two or three custom post types I wanted to include as well as my pages, I would write it like this?

    $query->set('post_type', array('post', 'pages', 'folio', 'newcustomposttype', 'anotherposttype'));

    That is correct. 🙂

    Do you know if it would be possible to apply this to just one search bar, while all the rest function normally?

    Any luck with category/tags? When a user selects a tag I want all my tagged custom posts to show up on the archives page with blog entries. Right now, only post show although I have tags enabled and set for other custom post types.


    I just add this as part of the array when creating a custom post type:
    'query_var' => true,

    Does anyone have a solution to @alanchrishughes question? I have a search form on one page that I only want to search and output a specific post type.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘How to Include Custom Post Types in Search Results and Archives’ is closed to new replies.