Custom post type not showing in search result

Please add exclude_from_search to false, inside your register post type function add_action(‘init’, ‘eyewebz_create_post_types’); function eyewebz_create_post_types() { register_post_type(‘project’, array( ‘taxonomies’ => array(‘category’), ‘labels’ => $labels, ‘has_archive’ => true, ‘show_in_rest’ => true, ‘hierarchical’ => true, ‘public’ => true, ‘publicly_queryable’ => true, ‘supports’ => array(‘title’, ‘editor’, ‘post-formats’, ‘page-attributes’, ‘thumbnail’, ‘excerpt’), ‘exclude_from_search’ => false, ‘menu_icon’ => ‘dashicons-index-card’ )); }

Including metaboxes from custom post types in global search — continued

I’ve figured out a fix. First, to fix bad results for an empty search, I require that (!empty(get_query_var(‘s’)) Before setting the “meta_query” query variable in my plugin. I thought the fix would be with the posts_request filter, but it continued to replace select SQL_CALC_GET_ROWS wp_posts.ID with select SQL_CALC_GET_ROWS wp_posts.* Even when I replaced the * … Read more

How do I add custom fields data to a search index?

Try adding the following code snippet to your functions.php file: /** * Extend WordPress search to include custom fields * * https://adambalee.com */ /** * Join posts and postmeta tables * * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join */ function cf_search_join( $join ) { global $wpdb; if ( is_search() ) { $join .=’ LEFT JOIN ‘.$wpdb->postmeta. ‘ ON ‘. $wpdb->posts … Read more