How to add extra meta fields to Woo Product Admin search

The Meta tab in Super Speedy Search is concerned with front-end search. Often, you will wish to allow additional fields to be searched from the WooCommerce Product Admin pages.

The _sku field is added and searched automatically.

To add extra post_meta keys as searchable from product admin, you’ll need to edit your functions.php file and add a new filter containing an array of the meta_keys you wish to search.

Example adding the Rank Math GTIN field to be searchable

Edit your functions.php file and add the following:

add_filter('sss_woo_admin_product_meta_keys', 'sss_woo_admin_product_meta_keys', 10, 1);
function sss_woo_admin_product_meta_keys($meta_keys) {
    $meta_keys[] = '_rank_math_gtin_code';
    return $meta_keys;
}

Adding multiple meta keys to be searchable from Woo product admin

To add multiple meta keys to your Woo product search from the wp-admin dashboard, just keep repeating the line which begins $meta_keys[] and add as many extra keys as you wish.
add_filter('sss_woo_admin_product_meta_keys', 'sss_woo_admin_product_meta_keys', 10, 1);
function sss_woo_admin_product_meta_keys($meta_keys) {
    $meta_keys[] = '_rank_math_gtin_code';
    $meta_keys[] = 'extra_meta_key';
    $meta_keys[] = 'a_third_meta_key';
    return $meta_keys;
}

Be the first to comment and we'll reply right away.

Leave a reply

Super Speedy Plugins
Logo