A
A
Artem Gvozdev2018-07-20 00:46:10
WordPress
Artem Gvozdev, 2018-07-20 00:46:10

Why is the Wordpress loop not working properly with the Woocommerce plugin?

The essence of the problem is this, if the loop is written like this:

<?php $country = new WP_Query( 
    array(
        'post_type' => 'product',
        'posts_per_page' => 10, 
'orderby' => array( 'title' => 'ASC', 'menu_order' => 'ASC' )
    )
); ?>

   <?php while ( $country->have_posts() ) : $country->the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     <?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?>

It outputs content like this:
5b5106762e2ba468341509.png
(should display horizontally)
If I comment out the cycle, it outputs it as it should, what's the problem?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2018-07-23
@arty23_03

Hello!
I'm not sure if it's the loop that's the problem, since you only provided a piece of code...
I can assume the following...
It wraps each product in this block, since it is in a cycle and, accordingly, due to CSS, each element is on a new line.
Check out this div's CSS... you should now have something like display:block; width:100% etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question