WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Get tags and query posts by tags in Woocommerce (2 posts)

  1. tiwelle
    Member
    Posted 1 year ago #

    Hello,
    I've been pulling my hair out for now 3 hours without finding any solution. I'm trying to query posts with same tag as my product tag.
    I can echo my tag before my query (see first line of code), it works, but then inside the query it all goes wrong.

    <?php echo $product->get_tags(); ?>
        <?php
    
         $producttags = get_tags();
    if ($producttags) {
        foreach($producttags as $tag) {
            $tag = $tag->slug;  break;
        }
    query_posts('tag='.$tag.'&posts_per_page=-1');
        while (have_posts()) : the_post(); ?>
        <div class="actucontent">
          <h3>
            <?php the_title(); ?>
          </h3>
          <?php the_content(); ?>
          <?php echo $tag ?> </div>
        <?php endwhile;
        wp_reset_query();
    }
    
        ?>

    webpage is http://www.tiwelle.com/sonneur/?product=lena
    Any idea someone ?
    Thank you,
    Manue

  2. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic