Pull Posts From a Category With A Specific Tag (2 posts)

  1. minolta1034
    Posted 7 years ago #

    I am trying to create an instance of the loop that pulls all posts from one category that have a specific tag which happens to be the title of the larger post that this smaller instance of the loop is on. here is the code im using:

    <?php rewind_posts(); ?>
    			<?php $tag = the_slug(); ?>
    			<?php $recent = new WP_Query("cat=755&tag=$tag&showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
    			<br />
    			<?php the_content(); ?>
    			<?php endwhile; ?>

    i know the problem is my WP_Query doesn't seem to want to take both the cat variable and the tag variable. Thanks for taking a look.

  2. raphaelhofer
    Posted 7 years ago #

    shouldn't it be:
    $recent = new WP_Query("cat=755&tag=".$tag."&showposts=5");
    to actually get the value of the tag var and not the value $tag?

Topic Closed

This topic has been closed to new replies.

About this Topic