• Resolved bgajus

    (@bgajus)


    I’m working with custom post types and taxonomies. Wondering if anyone knows of a way to create a secondary search that would limit results to only posts from that custom post type?

Viewing 3 replies - 16 through 18 (of 18 total)
  • How would you go about searching only two specific custom post types?

    @bgajus code worked easily for one post type

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

    but then if I tried to search two specific types

    `<input type=”hidden” name=”post_type” value=”one, two” />’

    did not work for either.

    Wow, what a useful piece of info. Thank you!

    Regarding multiple posts types, it seems that the WP_Query object can handle the ‘post_type’ parameter as an array. Therefore, it seems logical to me that if you were to pass a form array for post_type input name, it would work. I’m not in a position to test this right now, but would the following work?:

    <input type="hidden" name="post_type[]" value="post_type_one" />
    <input type="hidden" name="post_type[]" value="post_type_two" />
    <input type="hidden" name="post_type[]" value="post_type_three" />

    Hope that’s useful.

    @bgajus

    you’re a champ! thank you kindly

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Limit Search Results to Custom Post Type?’ is closed to new replies.