• I’d like to have our default site search only search post types that are set as "exclude_from_search" => false, but for Ajax requests that search posts via WP_Query and relevanssi_do_query() I’d like all post types searchable. What is the most efficient way of accomplishing this? I can determine which post types are excluded from search, but I’m just not sure which Relevanssi filters are best to use here. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter gavin310

    (@gavin310)

    Actually, I’m thinking about the best way to go about this and my approach above probably isn’t best. I’m using a single class for all Ajax searches, so in that class the best solution may be to simply fallback to a straight WP_Query if a post type is not indexed by Relevanssi. In that case I just need a way to get an array of all the post types Relevanssi is indexing. I’m looking through Relevanssi’s source code and it seems like the way to get an array of indexable post types is to use $types = get_option( 'relevanssi_index_post_types' );. Is that correct? Thanks!

    Plugin Author Mikko Saari

    (@msaari)

    How about you index all post types and then set the post_type parameter in the query according to what you want the query to return? That seems like the easiest solution to me.

    But yes, that’s how you get a list of post types indexed by Relevanssi.

    Thread Starter gavin310

    (@gavin310)

    @msaari Thanks. I assumed if I set Relevanssi to index all post types, then the global site search would return all post types, even if they are set to exclude_from_search=false. Is that not the case?

    Plugin Author Mikko Saari

    (@msaari)

    No, that’s not the case. Relevanssi respects the exclude_from_search (there’s an option in the Searching settings to ignore exclude_from_search, but it’s off by default). Also, if you want to control the post types, you can use the post_type parameter in the query to choose which post types are included.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Have all post types searchable via Ajax, but not sitewide search’ is closed to new replies.