Forums

Conditional Tag ? Help Please? (3 posts)

  1. CandyA21
    Member
    Posted 2 years ago #

    I'd like to set up some conditional tags for if the page showing is the photos page? I can't get it working correctly, this is in my single post template:

    <?php if ( is_page('Photos'))
    {
    <div id="copy">
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="navigation">
    <div class="alignleft">
    <?php previous_post_link('« %link') ?></div>
    <div class="alignright">
    <?php next_post_link('%link »') ?></div>
    </div>
    <div class="post">
    <?php the_content(); ?>

    </div><!-- /post -->
    }
    ?>

  2. Steffen Jørgensen
    Member
    Posted 2 years ago #

    This is the way I do it:

    <?php if (is_page('photos')) : ?>
    paste code here...
    <?php endif; ?>

    There are several ways to code conditional tags - I just feel that I have more controll of what's heppening this way.

    Maby is's because you have "Photos" insted of "photos"

  3. alchymyth
    The Sweeper
    Posted 2 years ago #

    'not working correctly' is not the most helpful of comments.
    i assume that your code is in page.php or a page template (not sure what you mean with 'single post template'?)
    (and you probably had some error message which could have helped here)

    i think you lost the closing php tags in the second line, and an opening php tag before the closing curly bracket - corrected code below:

    <?php if ( is_page('Photos'))
    { ?>
    <div id="copy">
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="navigation">
    <div class="alignleft">
    <?php previous_post_link('« %link') ?></div>
    <div class="alignright">
    <?php next_post_link('%link »') ?></div>
    </div>
    <div class="post">
    <?php the_content(); ?> 
    
    </div><!-- /post -->
    <?php
    }
    ?>

    btw - when you post code here, please use the 'code' button on top of the editor.

Topic Closed

This topic has been closed to new replies.

About this Topic