• Hi, I need to use WP Query (its requirement to use it, i cant use [products] shortcode!) to list my products in custom loop.

    <?php
    $params = array('posts_per_page' => 5); 
    $wc_query = new WP_Query($params); 
    ?>
    <?php if ($wc_query->have_posts()) : ?>
        <?php while ($wc_query->have_posts()) : 
                    $wc_query->the_post(); ?>
            <?php the_title(); ?>
    // and here i want a button 'add to wishlist'
        <?php endwhile; ?>
        <?php wp_reset_postdata(); ?>
    <?php else:  ?>
    <p><?php _e( 'No products here' ); ?></p>
    <?php endif; ?>
Viewing 1 replies (of 1 total)
  • Plugin Support Juan Coronel

    (@juaancmendez)

    Hi there,
    we hope you’re doing well!

    You can write the following code:
    echo do_shortcode( '[yith_wcwl_add_to_wishlist product_id="insert here the product_id"]' );

    Where in “insert here the product_id” you must enter the variable you use to obtain the product_id.

    Try it and tell us about any news.

    Have a nice day!

Viewing 1 replies (of 1 total)
  • The topic ‘How to display Wishlist button in WP query?’ is closed to new replies.