Product Icon

WooCommerce

Sell online with the flexible, customizable eCommerce platform designed to grow with your business. From your first sale to millions in revenue, Woo is with you. See why merchants trust us to power 3.4 million online stores.

Custom Post_Types Functionality

My Website is a car dealer, but Cars are not listed as “Products”. They`re listed as “Listings”.

These Listings have lots of informations such categories for example. I have Google Merchant and Facebook Pixel and i wanna to sincronize these Listings to my Dealer profile on Both Google and Facebook, but they need to be identified at Woocommerce Products lists.

I wanna to suggest WooCommerce to be able to identify these Listings at Products Listing.
And i believe it could be done by using the “pre_get_posts” filter.

function incluir_listings_na_consulta_produtos( $query ) {
// Verifica se não é a área administrativa e se é a query principal
if ( ! is_admin() && $query->is_main_query() ) {
// Se for a página da loja, de categoria ou tag de produto
if ( is_shop() || is_product_taxonomy() ) {
// Define que a consulta deve buscar por ambos os post types
$query->set( ‘post_type’, array( ‘product’, ‘listings’ ) );
}
}
}
add_action( ‘pre_get_posts’, ‘incluir_listings_na_consulta_produtos’ );

Author

creondai

Current Status

Open

Last updated: February 13, 2025

0 comments

Log in to comment on this feature request.