- <?php
- /**
- * Template Name: Bjuuti kampaania Template
- */
- defined( 'ABSPATH' ) || exit;
- get_header( );
- $args = array(
- 'post_type' => array('product', 'product_variation'),
- // 'posts_per_page' => -1, // Set to -1 to retrieve all products.
- 'posts_per_page' => 12,
- 'paged' => $paged,
- 'meta_query' => array(
- array(
- 'key' => 'bjuuti', // Replace with your custom field name.
- 'value' => '1', // Only show products with this value.
- 'compare' => '=',
- ),
- ),
- );
- $custom_query = new WP_Query($args);
- if ( $custom_query->have_posts() ) :
- while ($custom_query->have_posts()) {
- $custom_query->the_post();
- wc_get_template_part('content', 'product-cat'); // This loads the product content template.
- }
- // Pagination.
- echo '<div class="pagination">';
- echo paginate_links(array(
- 'total' => $custom_query->max_num_pages,
- 'current' => max(1, get_query_var('paged')),
- ));
- echo '</div>';
- else :
- echo 'No products found.';
- endif;
- wp_reset_postdata(); // Reset the post data to avoid conflicts.
- get_footer( );