• blackbookdesign

    (@blackbookdesign)


    Hi guys,

    I am trying to make a conditionnal comment work with is_page_template.

    <div id="nav">
        <ul
    		<?php if ( is_page_template('what.php') ) { echo ' class="what"';} ?>
            <?php if ( is_page_template('who.php') ) { echo ' class="who"';} ?>
            <?php if ( is_page_template('where.php') ) { echo ' class="where"';} ?>
         >
    
         <li id="who"><a href="<?php bloginfo('url'); ?>/who">Who?</a></li>
         <li id="what"><a href="<?php bloginfo('url'); ?>/what">What?</a></li>
         <li id="where"><a href="<?php bloginfo('url'); ?>/where">Where?</a></li>
    </ul>

    It’s suppose to put a class when the page tempalte is being used but it actually not working.

    Could it be that those page templates don’t really have any content but fetching post from categories? meaning that they don’t print any content from that actual page but still use the template.

    here is an example:

    <?php
    /*
    Template Name: who.php
    */ ?>
    <?php get_header(); ?>
    <div class="posts-wrap"> 
    
    <!-- profile -->
    
        <?php query_posts('page_id=60');?>
        	<div class="profile">
        	<?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
        				<H2><?php the_title(); ?></H2>
                                <div id="line" style="margin-top:10px;"></div>
    			<?php the_content( __('')); ?>
    		<?php endwhile; ?><?php else : ?><?php endif; ?>
       		 </div>
    
    <!-- people -->
    	<div><h2>Directors</h2></div>
        <div id="line" style="margin-top:10px;"></div>
    
    	<?php query_posts("cat=4");?>
            <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
            <div class="directors">
                <div class="directorspic"><?php echo c2c_get_custom('who'); ?></div>
                <div class="directorstext">
                <H3><?php the_title(); ?></H3>
                      <?php the_content( __('')); ?>
                </div></div>
                <br clear="all" />
            <?php endwhile; ?><?php else : ?><?php endif; ?>
    
     </div><!-- end .posts-wrap -->
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH

    (@michaelh)

    is_page_template() returns false if is_page() is false.

    It will also return false if the Template is not the Page Template for that Page also.

    Thread Starter blackbookdesign

    (@blackbookdesign)

    hummm still ain’t working.

    1) page template is called on that page. (so is_page id should be true)
    2) is_page_template is called but returns false.

    Well I’ve decided not to bang my head anymore and place the sidebar in the actual page template instead of calling sidebar.php

    its bad but it works… but not like I want! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with is_page_template’ is closed to new replies.