How to add custom meta to 'pre_get_terms'?
I have a custom taxonomy with custom meta. I have added the custom meta values to columns in the admin list page just fine. But if I search for values that are in these columns nothing is found. I'm assuming I need to use pre_get_terms
, but am having trouble figuring out how to include the meta in the query.
Here is what I am trying to do to test one of the fields, but results are still negative.
add_action( 'pre_get_terms', [$this, 'filter_feedback_stats_admin_columns'] );
public function filter_feedback_stats_admin_columns( $query ) {
// Get the page
global $pagenow;
// Only if current post taxonomy or edit page in admin
$taxonomy = isset($_GET['taxonomy']) ? $_GET['taxonomy'] : '';
if ( !is_admin() || $pagenow !== 'edit-tags.php' || $taxonomy != 'feedback-stats' !isset($_GET['s'])) {
return $query;
}
// Search keyword
$s = $_GET['s'];
// // store current query vars
$query_vars = $query-query_vars;
$args = [];
// set meta query
$args['meta_query'] = [
[
'key' = 'access_id',
'value' = $s,
'compare' = 'LIKE'
]
];
// Add it
$query-query_vars = array_merge( $query_vars, $args );
}