• Resolved Erick Jones

    (@erick-jones)


    I am using is_tag() as a boolean to loop the posts with some specific tag, but with no results.

    See the code:

    <?php if( is_tag('destaque')): ?>
        <?php $posts = get_posts('numberposts=4'); foreach($posts as $post) { ?>
           <h2><?php the_title(); ?></h2>
        <?php } ?>
    <?php endif ?>

    Does somebody knows how to do that? Am I doing something wrong?
    Thank you all.

Viewing 1 replies (of 1 total)
  • Thread Starter Erick Jones

    (@erick-jones)

    Ok, I’m new to wordpress and did’n know how to make the loop correctly.
    The solution I was looking for was:

    <?php $p = new WP_Query("tag=destaque-2&showposts=4"); ?>
        <?php if($p->have_posts()) : while($p->have_posts() ): $p->the_post(); ?>
             <h3><?php the_title(); ?></h3>
             <p><?php the_content(); ?></h3>
    
    <?php endwhile; endif; ?>
    <?php wp_reset_query(); ?>

    I hope this can help another noobs.

Viewing 1 replies (of 1 total)
  • The topic ‘List specific tag in a page’ is closed to new replies.