Support » Fixing WordPress » if is home includes not working 2.8.6?

  • Resolved Mobster


    What could be causing this to not work in 2.8.6?

    <?php if ( is_home() ) { include ('mypage.php'); } ?>

Viewing 12 replies - 1 through 12 (of 12 total)
  • esmi


    Forum Moderator


    <?php if ( is_home() ) { include (TEMPLATEPATH . 'mypage.php'); } ?>

    I’m assuming that mypage.php is in your current theme folder, yes?

    Yes it is. That’s not working either?



    Forum Moderator

    Plan B:

    <?php if ( is_home() || is_front_page() ) { include (TEMPLATEPATH . 'mypage.php'); } ?>

    Well… I appreciate your help but neither are doing the trick. They make sense though…

    Isn’t there a stylesheet directory version of this?



    Forum Moderator

    Not that I recall. TEMPLATEPATH is the correct constant – although:

    `<?php if ( is_home() ) { include (TEMPLATEPATH . ‘/mypage.php’); } ?>

    might work a lot better. I forgot that TEMPLATEPATH doesn’t include a trailing /. >:(

    This is crazy. None of the above work. I have used just about every version include tag you mentioned for what seems like years with no issues? Could this be a bug of some sort?

    Are you seeing an error message, “Failed to include”… etc etc..

    If you don’t see an error it could be that the file is getting included but simply not producing an output..

    If no error, try changing to a require, and see if it then bombs out..

    Nope, No errors.

    This works:

    <?php include( TEMPLATEPATH . '/mypage.php' ); ?>

    This doesn’t:

    <?php if ( is_home() ) { include ( TEMPLATEPATH . '/mypage.php'); } ?>

    Why not in 2.8.6? I guess that’s the million dollar question considering all of the above are played out as methods to include in wordpress documentation?

    WordPress Codex

    I smell a bug…

    Ok, I think I’m on to something here.

    I ran across an include in my code I forgot about.

    Here it is:

    <?php if ( is_home() ) { include ('mypage.php'); } ?>

    It works perfectly. I experimented buy putting the same code right below it and it only included one instance.

    Has there been some sort of limit to the amount of if’s or if homes allowed on one page?

    Just a guess…

    Another issue, my custom queries aren’t working.

    <?php $recent = new WP_Query("cat=5&showposts=5");  ?>
                        <?php while ($recent->have_posts()) : $recent->the_post(); ?>
                        <a href="<?php the_permalink() ?>" title="<?php _e('Permanent link to'); ?>
    <?php the_title(); ?>">
                        <?php the_title(); ?>
                        <?php endwhile;?>

    Aren’t working in what way, no output, an error?.. (problem code usually at least outputs an error).

    Dump your query data onto the screen so you can make sure it exists..

    <pre><?php print_r( $recent ); ?></pre>


    There’s also WP_DEBUG for debugging purposes to..

    Before you go fiddling or digging in more code though, noone has brought it up… but do you have any plugins enabled, and if so, have you tested (if only for testing sake) with them disabled?
    Also tried another theme also perhaps? … again if only for testing sake…

    Thanks t3 for taking the time to assist me.

    I went through all the normal testing I always do by disabling plugins, testing bits of code. ect…

    The next thing I always try is phpMyAdmin optimize table and repair table. This time, that did the trick.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘if is home includes not working 2.8.6?’ is closed to new replies.