Custom Fields Not in Search Results

I noticed that the content of my custom fields is not in my search results. Is there a good remedy for this?

I could just hardcode my content into page templates but I would like the content to be searchable.

Read More

Thanks.

Related posts

Leave a Reply

1 comment

  1. You can use an custom plugin for your custom fields

    function fb_custom_search_where($where) {
        // put the custom fields into an array
        $customs = array('custom_field1', 'custom_field2', 'custom_field3');
    
        foreach( $customs as $custom ) {
        $query .= " OR (";
        $query .= "( m.meta_key = '$custom' )";
        $query .= " AND ( m.meta_value  LIKE '{$n}{$term}{$n}' )";
            $query .= ")";
        }
    
        $where = " AND ({$query}) AND ($wpdb->posts.post_status = 'publish') ";
        return($where);
    }
    add_filter( 'posts_where', 'fb_custom_search_where' );
    

    Also you can check the plugin WP Custom Fields Search and you have adhoc an solution.