Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Is Relevanssi enabled in admin?

    Thread Starter greatmatter

    (@greatmatter)

    Yes, it is. I’ve tried toggling that, as well as deactivating/reactivating the plugin.

    Plugin Author Mikko Saari

    (@msaari)

    Hmm. I checked this, and it works fine. I get an URL like this:

    wp-admin/edit.php?s=repeat&post_status=all&post_type=post&action=-1&m=0&cat=0&paged=1&mode=list&action2=-1

    and see the posts that have the word “repeat” inside a custom field. If that doesn’t work on your site, I don’t know… How does the URL look like when you do a search that doesn’t provide the expected results?

    Thread Starter greatmatter

    (@greatmatter)

    /wp-admin/edit.php?s=5340&post_status=all&post_type=vehicles&action=-1&m=0&cpac_filter%5Bcolumn-taxonomy-2%5D&cpac_filter%5Bcolumn-taxonomy%5D&cpac_filter%5Bcolumn-taxonomy-1%5D&paged=1&action2=-1

    Plugin Author Mikko Saari

    (@msaari)

    cpac_filter –?so you’re using ACF and not regular custom fields? I don’t know if that’s going to work.

    Thread Starter greatmatter

    (@greatmatter)

    We’re using Pods and Admin Columns Pro, not ACF. Any thoughts?

    Plugin Author Mikko Saari

    (@msaari)

    I don’t know about those. Is the data you’re looking for inside a regular custom field?

    Thread Starter greatmatter

    (@greatmatter)

    Yes–it’s a normal field.

    Plugin Author Mikko Saari

    (@msaari)

    OK, in that case I don’t know why it’s not working – it certainly should be. Probably some kind of conflict with the plugins you’re using.

    Thread Starter greatmatter

    (@greatmatter)

    Ok–we’ve deactivated almost all of the plugins (we left Admin Columns Pro because we need that field) and it still didn’t work. Any other ideas?

    Thread Starter greatmatter

    (@greatmatter)

    Quick update…this only doesn’t work with one of the post types.

    Thread Starter greatmatter

    (@greatmatter)

    A little more in the way of updates… I started doing more code-debug, and found that when I dumped the query at line 256 of search.php:

    if (is_array($meta_query)) {
    		$meta_query_restrictions = "";
    
    		$mq_vars = array('meta_query' => $meta_query );
    
    		$mq = new WP_Meta_Query();
    		$mq->parse_query_vars( $mq_vars );
    		$meta_sql = $mq->get_sql('post', 'relevanssi', 'doc');
    		$meta_join = "";
    		$meta_where = "";
    		if ($meta_sql) {
    			$meta_join = $meta_sql['join'];
    			$meta_where = $meta_sql['where'];
    		}
    
    		// $query_restrictions .= $meta_where;
    	}

    the query had
    ...AND ( ( wp_postmeta.meta_key = 'vehicle_make' AND CAST(wp_postmeta.meta_value AS CHAR) = '' )
    That would absolutely cause the search to show no results. Why would it be adding in the meta_key requirement here?

    Plugin Author Mikko Saari

    (@msaari)

    Because you have a meta key sorting involved in the search. It causes a meta_key field appear in the query, and Relevanssi interprets that as a meta filter, which it isn’t.

    Add a filter function on relevanssi_modify_wp_query, you can probably remove that meta query from there.

    Thread Starter greatmatter

    (@greatmatter)

    I’d love a bit more guidance–should I add that as a hook, and if so, where? Obviously not the theme, but maybe a custom plugin?

    Thread Starter greatmatter

    (@greatmatter)

    Or, even better, how do I remove if via the GUI? I don’t understand why it’s there in the first place.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Admin Search on Custom Fields Showing No Results’ is closed to new replies.