Support » Plugin: Simple Fields » Slug names as meta keys?

  • First, thanks for the great plugin, it’s solved a lot of problems for me already.

    I’m trying to include custom (simple) fields as searchable terms.

    I have a hook for the posts_where search filter, and I’m trying to use the postmeta.meta_key to match against a custom field.

    function custom_search_where($where)
    	if (is_search())
    	 	global $wpdb;
    		$where .= " OR (($wpdb->postmeta.meta_key = 'custom_field_slug') AND ($wpdb->postmeta.meta_value LIKE 'some_value'))";
    add_filter('posts_where', 'custom_search_where');

    I’d assumed the slug I entered when creating the simple field would be used as the meta_key, but it doesn’t seem to be the case.

    From what I can tell, the actual meta keys assigned when creating a simple field, are along the lines of:


    Can you confirm if this is the case? If so, is there any way for me to get these values, referenced by slug name?

    Alternatively, is there another way of including simple fields in search queries?

    I’ve tried the Search Simple Fields plugin but it doesn’t seem to work.


  • The topic ‘Slug names as meta keys?’ is closed to new replies.