Skip Navigation

[Resolved] Issues to exclude from search results for a custom post type

This support ticket is created 7 years, 12 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by MiquelC1907 7 years, 12 months ago.

Assisted by: Luo Yang.

Author
Posts
#393802

I'm trying to exclude from the search results a custom post type, called "Houses", as this is confidential information from the registered users.

For this CPT , I've checked the Types custom post setting called "exclude_from_search" which is supposed to allow the functionality I want.

With this setting enabled, the results page after a search, is still listing the non wanted "Houses" CPT.

Any idea about what might be wrong?

Thanks for your help,

Miquel

#394136

Dear Miquel,

The option "exclude_from_search" is for wordpress build-in search feature.

How do you setup the search result page and search form?
Have you tried to deactivate other plugins, and switch to wordpress default theme, and test again?

#394706

Dear Luo,

I've managed to avoid that House CPT instances are included in the search query, by adding the WordPress action below. I don't know yet, what it is for the "exclude_from_search" setting....

add_action('pre_get_posts','KY_SearchFilter');
function KY_SearchFilter($query) {
     if ( !is_admin() && $query->is_main_query() ) {
	  if ($query->is_search) {
		$query->set( 'post_type', array('post','page','product','portfolio') );
	   }
     }
}

Another setting with an unexpected behaviour is the "publicly_queryable" setting, which can be set up with Types, when creating a CPT.

When this setting is disabled, on CRED, you can not select this CPT on the select box : "Choose the type of content the form will create or modify".
This setting is supposed to only affect the frontend queries, and not the queries when designing a new form on CRED.

I set this thread as resolved as I've found work arounds for both issues.

Thanks,

Miquel

#395851

As a final finding, the CPT "publicly_queryable" setting is ignored or modifed by the ACCESS plugin.

As soon as the Post Type is set to "Managed by Access" (in the ACCESS plugin configuration page), it becomes publicly queriable in the frontend, despite of the setting in the TYPES plugin options .

Writing here just in case it can help to improve the plugin behaviour,

All the best,
Miquel

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.