Display Custom Post type in WooCommerce Product loop

29 views Asked by At

I've created a custom post type called "promo" with a meta field named "position." The admin can add any number of promos and assign a numeric value to the position field.

Now, when a user visits the WooCommerce shop page, I want the promos to appear between the products. For example, if a page has 12 products and the admin adds a promo with position 5, the promo should appear at position 5 within the product loop.

I've attempted to use the 'woocommerce_shop_loop' action, but it disrupts the pagination. Is there another solution to achieve this functionality without affecting pagination?

add_action( 'woocommerce_shop_loop', 'wc_shop_loop', 100 );


With custom product loop as well

$args = array(
        'status' => 'publish',
        'category' => isset($term->slug) ? array( $term->slug ) : '',
        'limit' => $products_per_page,
        'page' => $paged,
        'paginate' => true,
        'return' => 'ids',
        'orderby' => $ordering['orderby'],
        'order' => $ordering['order'],
    );

    $products_ids = wc_get_products($args); 
0

There are 0 answers