I am building a WordPress website using WooCommerce and Elementor, and I want to display a list of products in a custom Elementor Loop based on a custom product meta field.

I have a custom field featured_color (added via update_post_meta) for each product. For example:

Product A → featured_color = "red"

Product B → featured_color = "blue"

Product C → featured_color = "red"

I want Elementor to show only products where featured_color = red in a custom section.

I tried using a custom query in functions.php:

function custom_elementor_query( $query ) { $query->set( 'meta_key', 'featured_color' ); $query->set( 'meta_value', 'red' ); } add_action( 'elementor/query/my_custom_filter', 'custom_elementor_query' );

It partially works, but:

Sometimes products do not appear even though the meta is set

Pagination breaks when multiple products match

Not sure if this is the correct way to filter WooCommerce products by meta in Elementor

Questions:

What is the proper way to filter WooCommerce products by custom meta for an Elementor Loop?

How can I ensure pagination works correctly with a custom query?

Are there any performance issues when using meta_query for many products?

Environment:

WordPress 6.x

WooCommerce 10.x

Elementor 3.x

Theme: Astra

Amina's user avatar

New contributor

Amina is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Proper Way to Filter WooCommerce Products by Custom Meta in Elementor Loop function custom_elementor_query( $query ) { $meta_query = array( array( 'key' => 'featured_color', 'value' => 'red', 'compare' => '=', ), ); $query->set( 'post_type', 'product' ); $query->set( 'post_status', 'publish' ); $query->set( 'meta_query', $meta_query ); } add_action( 'elementor/query/my_custom_filter', 'custom_elementor_query' );

Manpreet kaur's user avatar

New contributor

Manpreet kaur is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

2026-02-18T05:42:11.653Z+00:00

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.