• Resolved tsea

    (@tsea)


    I have custom wp_queries that would like to add the hearts to is there any way to do this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Pablo Pacheco

    (@karzin)

    Hello @tsea,

    I don’t know if I got it.
    Can you explain it with more details?

    Thread Starter tsea

    (@tsea)

    I have a WP_query like the one below.

    `$args = array(
    ‘post_type’ => ‘product’,
    ‘posts_per_page’ => 5,
    );
    $loop = new WP_Query( $args );
    if ( $loop->have_posts() ) {
    while ( $loop->have_posts() ) : $loop->the_post();

    <?php the_post_thumbnail(‘medium’);?>

    <?php endwhile;}
    wp_reset_postdata();
    ?>
    `

    The results of this query do not have the hearts to add to wish list.
    Is there some thing i could pass in the query to add hearts to the query results.

    • This reply was modified 7 years, 7 months ago by tsea.
    • This reply was modified 7 years, 7 months ago by tsea.
    Plugin Author Pablo Pacheco

    (@karzin)

    I’ve never tested but maybe it’s possible.

    1- Inside your loop you have to trigger a hook that will make the heart button be displayed:
    do_action( 'woocommerce_before_shop_loop_item' );

    2- Besides that you’ll have to add some css classes.
    You have to add ‘woocommerce’ to your ‘body’ element. It doesn’t have to be the body necessarily, but on some wrapper element.

    3- You also have to add a ‘products’ css class to your loop wrapper, preferably like this:

    <ul class="products">
         <li class="product"></li>
         <li class="product"></li>
    </ul>

    I hope it helps you. Tell me if you had any luck ??
    See you

    Thread Starter tsea

    (@tsea)

    yes, do_action( 'woocommerce_before_shop_loop_item' );

    Putting that action in the loop worked, thank you!

    I’ll be leaving a 5 star review great plugin.

    Plugin Author Pablo Pacheco

    (@karzin)

    Thanks!
    I really appreciate that

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add heart to WP_Query’ is closed to new replies.