Can NOT search my custom post type?

did you try if (!isset($post_type)) or if(empty($post_type))?? For example I would try this: function mySearchFilter($query) { $post_type = $_GET[‘post_type’]; if ($query->is_search) { if (!empty($post_type)) { $query->set(‘post_type’, $post_type); } } return $query; } add_filter(‘pre_get_posts’,’mySearchFilter’); EDIT: Here is my working example code: Here is my CPT used for testing: add_action( ‘init’, ‘register_cpt_website_bookmarks’ ); function register_cpt_website_bookmarks() { $labels … Read more

cannot override post_types in WP_Query()

First of all,while( have_posts()): should be while( $ml_featured->have_posts()): And secondly, in your pre_get_posts callback you check: false == $query->query_vars[‘suppress_filters’] But this returns true for every WP_Query query and any get_posts query where ‘supress_filters’ is explicitly set to false. If you want to check if the query is the ‘main’ query (i.e. query associated with the … Read more

Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view

Start by reading the notices–they tell you very explicitly what the problem is. Let’s start with the first one: Notice: Undefined index: _wr_event_speaker in /Users/my/htdocs/wr/wp-content/themes/wr/functions.php on line 246 First, this is just a “notice”. Meaning that no error has actually occurred. PHP is just telling you that something isn’t quite right, but that it skipped … Read more