• faidonas

    (@faidonas)


    I would like to create a page template that displays a set of posts/excerpts based on both categories and tags.
    Since it is a template, I would like to use variables instead of specific values, so that I can apply it to different pages.

    Here is what works using if and elseif:

    $wall = 14 
    
    Page 2
    $wall = 16;

    Page 3
    $wall = 18

    <?php query_posts('cat=$wall&tag=red+red&showposts=2&offset=1');
    while (have_posts()) : the_post(); ?>
    <b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
    <?php the_excerpt(__('Read more'));?><div style="clear:both;"></div>
    <?php endwhile; ?><br />

    here is what I would like to make it do

    Page 1
    $wall = 14
    $colour = black

    Page 2
    $wall = 16 or 17
    $colour = red

    Page 3
    $wall = 18 or 19 (how do I do that?)
    $colour = (yellow or orange) and white (how do I do that?)
    (Need help with the syntax above…)

    And the code in the loop:

    <?php query_posts('cat=$wall&tag=$colour&showposts=2&offset=1');
    while (have_posts()) : the_post(); ?>
    <b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
    <?php the_excerpt(__('Read more'));?><div style="clear:both;"></div>
    <?php endwhile; ?><br />

    Of course there is no output.
    Any ideas?
    Thank you in advance

  • The topic ‘a variable instead of a name for Tag tag in query_posts’ is closed to new replies.