• Hi
    I have a problem with includes.
    In index.php I have this code:

    <?php include (TEMPLATEPATH . '/file1.php'); ?>
    <?php include (TEMPLATEPATH . '/file2.php'); ?>
    Both of them have the same code:
    
    <?php if (is_page())
    	{
    		echo 'I am a page';
    	}
    	else
    	{
    		echo 'I am not a page';
    	}
    	?>

    This only works in file1.php and fails in file2.php

    Anybody knows why?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter grunlof

    (@grunlof)

    No ideas??
    Please

    You need to give us more code – that’s not enough to go on.

    Thread Starter grunlof

    (@grunlof)

    Ok.
    This is my index.php

    <?php get_header(); ?>
    <div id="wrapper">
    <div class="head">
    <h1><span><a>/" title="Hompage"><?php bloginfo('name'); ?></a></span></h1>
    <?php include (TEMPLATEPATH . '/searchform.php'); ?><br class="clear" />
    </div>
    <div class="content">
    <?php if (have_posts()) : ?>
    
    <?php  if (is_category()) { ?>
    <h2><?php echo single_cat_title(); ?></h2>
    <?php  } elseif (is_single()) { ?>
    <h2><?php the_title(); ?></h2>
    <?php } elseif (is_home()) { ?>
    <h2>News</h2>
    <?php  } elseif (is_day()) { ?>
    <h2>Articles <?php the_time('j \d\e F \d\e Y'); ?></h2>
    <?php  } elseif (is_month()) { ?>
    <h2>Articles <?php the_time('F \d\e Y'); ?></h2>
    <?php  } elseif (is_year()) { ?>
    <h2>Articles <?php the_time('Y'); ?></h2>
    <?php } elseif (is_search()) { ?>
    <h2>Results</h2>
    <?php  } elseif (is_author()) { ?>
    <h2>About</h2>
    <?php } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    <h2>Archive</h2>
    <?php } ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php if (in_category('10')) continue; ?>
    <h3><a>" title="<?php the_title(); ?>"><?php the_title() ?></a></h3>
    <small><?php the_time('j \d\e F \d\e Y') ?></small>
    <?php the_content('(more...)'); ?>
    <?php endwhile; ?>
    <?php else : ?>
    <h2>Not found</h2>
    text
    
    <?php endif; ?>
    <p class="masizq"><?php next_posts_link('&laquo; old') ?>
    
    <p class="right"><?php previous_posts_link('next &raquo;') ?>
    
    </div>
    
    </div>
    
    <?php include (TEMPLATEPATH . '/column2.php'); ?>
    
    <?php include (TEMPLATEPATH . '/column3.php'); ?>
    <br class="clear" />
    </div>
    
    <?php get_footer(); ?>
    </body>
    </html>

    And in both includes I have the same code:

    <?php if (is_page())
    {
    echo 'I am a page';
    }
    else
    {
    echo 'I am not a page';
    }
    ?>

    The problem is that first include shows me “I am a page” but the second one shows me “I am not a page”.

    I cant find a solution.

    Thread Starter grunlof

    (@grunlof)

    My problem really is like in this post:
    http://wordpress.org/support/topic/89404?replies=6

    But I cant understand how to resolve it. :s

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