0

I am trying to be able to search a particular custom post type on my blog. The custom post type is named: website_bookmarks

I have modified my search form with a hidden field

<input type="hidden" name="post_type" value="website_bookmarks" /> 

So on my search page in the URI I will see...

www.mydomain.com/?s=mysearchterm&post_type=website_bookmarks

The problem is it ONLY shows search results for my regular blog post and no results from my custom post type.

It should not be showing any results for my blog post and ONLY results for my custom post type website_bookmarks

Can someone help me? I can not figure out why it will not work and it will work on other people blogs simply by changing the search form to what I did above.

0

Could you check one thing for me: http://codex.wordpress.org/Function_Reference/register_post_type

When you register website_bookmarks is:

exclude_from_search

(boolean) (importance) Whether to exclude posts with this post type from search results.

Set to false?

  • hello, thanks for reply, and yes I have that set to false and public, public_queryable,show_ui, query_var all set to true, it is a strange issue – JasonDavis Sep 26 '11 at 9:54
0

Make sure you have this code still there

   <input type="text" name="s" placeholder="Search"/>

so complete Code should looks like

<form role="search" action="<?php echo site_url('/'); ?>" method="get" id="searchform">
<input type="text" name="s" placeholder="Search"/>
<input type="hidden" name="post_type" value="website_bookmarks" />
<input type="submit" alt="Search" value="Search" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.