I came across a situation today where a plugin had registered a custom post type and I needed to change some of that configuration, namely I wanted to exclude the post type from search results. The solution is pretty simple.

One solution is to modify the plugin which I did not want to do since the plugin would become version locked or an upgrade would break my fix. I decided I would modify the configuration after the plugin had been registered so I could make the change in my theme.

// functions.php

add_action( 'init', 'updateSidebarsPostType', 99 );

/**
 * updateSidebarsPostType
 *
 * @author  Joe Sexton <joe@webtipblog.com>
 */
function updateSidebarsPostType() {
	global $wp_post_types, $wp_rewrite;

	if ( post_type_exists( 'multiple-sidebars' ) ) {

		// exclude from search results
		$wp_post_types['multiple-sidebars']->exclude_from_search = true;
	}
}

In this example the custom post type is multiple-sidebars and the configuration I changed was exclude_from_search = true so the sidebar posts would not show up in search results. You could change any of the configuration options for the post type using this method. I also added a check if the post type exists so the code won’t break if the plugin is removed.

One thing to note is what hook to use, which is probably going to be ‘init’ but could be anything depending on how the plugin registered the post type. In my situation the plugin hooked onto the ‘init’ action with default priority. I set a priority of 99 to ensure my update would come after the plugin had registered the plugin.