• I can’t seem to get this to work (even though it seems like it should from the codex).

    <?php if (have_posts()) : ?>
    <?php query_posts("showposts=4&tag=featured"); ?>
    <?php while (have_posts()) : the_post();?>

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • what is it doing or not doing?

    is there more code to it?

    you could paste the whole code of the template (or whatever you are working on) into a https://pastebin.com/ and post the link to it here.

    Thread Starter evaneckard

    (@evaneckard)

    I was simply trying to open the loop showing only 4 posts tagged with “featured”

    If I use just showposts=4, the loops shows the most current 4 posts. If I use just the tag, nothing shows even though I have posts tagged as such.

    Looking at the codex, it seems it should work.

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('posts_per_page=4&tag=featured&paged=. $paged); ?>

    you could try a variation:

    <?php $args = array(
    'posts_per_page' => 4,
    'tag_slug__in' => array('featured')
    );
    query_posts( $args ); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post();?>

    https://codex.www.ads-software.com/Class_Reference/WP_Query#Tag_Parameters

    or check the spelling; or try and use the tag ID …

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘query_posts by tag and showposts’ is closed to new replies.