Answer the question
In order to leave comments, you need to log in
How to fix php output of products through Wp_Query?
I used the Themify plugin to filter products by attributes and price range, edited its cycles and fields for myself, in fact changed the plugin for myself.
It filters well through ajax cycles of products that are called through a shortcode, but shortcodes do not suit me, because I have no idea how to use hooks and I'm just looking for a way to display a cycle in php where I can put any class on each block. I found the WP_QUERY output for myself, it suits me from the visual part, but there is one "but". The block with the WP_QUERY loop does not react in any way to filtering through this plugin . Or rather, even to say that there is an imitation of activity, but there is no filtering as such.
First of all, I thought that the correct attributes were not specified in array.
<?php
$loop = new WP_Query( array(
'post_type' => 'product',
'posts_per_page' => '12',
));
while ( $loop->have_posts() ): $loop->the_post(); ?>
<div <?php post_class("catalog-block"); ?>>
<a href="" class="image"><?php the_post_thumbnail("thumbnail-215x300"); ?></a>
<div class="name"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<?php woocommerce_template_loop_price(); ?>
<?php woocommerce_template_loop_add_to_cart(); ?>
</div>
<?php endwhile; wp_reset_postdata(); ?>
<?php
$catalog_orderby = apply_filters( 'woocommerce_catalog_orderby', array(
'menu_order' => __( 'Default sorting', 'woocommerce' ),
'price' => __( 'Sort by price: low to high', 'woocommerce' ),
'price-desc' => __( 'Sort by price: high to low', 'woocommerce' )
) );
if ( get_option( 'woocommerce_enable_review_rating' ) == 'no' )
unset( $catalog_orderby['rating'] );
foreach ( $catalog_orderby as $id => $name )
echo '<li>
<span class="filter-checkbox sort-hover">
<a href="' . get_permalink( woocommerce_get_page_id( 'shop' ) ) . '?orderby=' . $id . '" >' . esc_attr( $name ) . '</a>
</span>
</li>';
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question