WordPress.org

Ready to get started?Download WordPress

Forums

Category tags (2 posts)

  1. Shonari
    Member
    Posted 6 years ago #

    I use a special template to control what is displayed on a certain page.

    basically it says:

    show 3 posts that are in the category y on this page.

    What i wanted to do is to modify that same template to create something like an array that says:

    if page id= x
    display categories=w, y, z

    if page id= y
    display posts in category t, u, v

  2. SimonJ
    Member
    Posted 6 years ago #

    Yo!

    http://codex.wordpress.org/Conditional_Tags

    http://codex.wordpress.org/Template_Tags/query_posts

    <?php
    if ( is_page('10') ) : ?>
    <?php query_posts('cat=2,3,4&showposts=3'); ?>
    <?php endif; ?>
    
    <?php
    if ( is_page('11') ) : ?>
    <?php query_posts('cat=5,6,7&showposts=3'); ?>
    <?php endif; ?>
    
    <?php while (have_posts()) : the_post(); ?>
    DO YOUR STUFF (date, title, author, wathever)
    <?php endwhile; ?>

    You can put as many "IF" as you want... Of course, you change the code above to fit your page ID number and the cat_ID number you want to display...

    S.

Topic Closed

This topic has been closed to new replies.

About this Topic