ThemeShaper Forums » Thematic

[closed]

Conditional statement to show one of two possible query_posts()

(1 post)
  • Started 7 years ago by sixfootjames
  • This topic is not resolved
  1. Hi all,

    I have created a specific template page that needs to show the content of one of two categories.

    I am not sure if I should be doing this in the functions.php file because I am not sure how to hook the functions.php file up to this specific template page. What I need is a conditional statement, that will check if we are in a particular category.

    Here's the working code for one category

    <div class="entry-content">
            <h1><?php  the_title(); ?> </h1>
            <?php query_posts('cat=5&posts_per_page=4');
                if (have_posts()) : while (have_posts()) : the_post();?>
                <h2><?php the_title();?></h2>
                <?php
                    global $more;
                    $more = 0;
                    the_content();
                    endwhile; endif;
                    // Reset Query
                    wp_reset_query();
                ?>
    
    </div>

    What I need is something like this:

    <div class="entry-content">
    if (category == 'category1')
    {
    
            <h1><?php  the_title(); ?> </h1>
            <?php query_posts('cat=5&posts_per_page=4');
                if (have_posts()) : while (have_posts()) : the_post();?>
                <h2><?php the_title();?></h2>
                <?php
                    global $more;
                    $more = 0;
                    the_content();
                    endwhile; endif;
                    // Reset Query
                    wp_reset_query();
                ?>
    
    } else if (category == 'category2')
    {
    
            <h1><?php  the_title(); ?> </h1>
            <?php query_posts('cat=6&posts_per_page=4');
                if (have_posts()) : while (have_posts()) : the_post();?>
                <h2><?php the_title();?></h2>
                <?php
                    global $more;
                    $more = 0;
                    the_content();
                    endwhile; endif;
                    // Reset Query
                    wp_reset_query();
                ?>
    
    }
    </div>

    Helga, if you are the first to answer, I know we are going through a similar exercise but this one is not related ;) This one is specific to this template problem I am having. :)

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.