The MU forums have moved to WordPress.org

is_home and is_front_page in sidebars (1 post)

  1. greg.hellings
    Member
    Posted 15 years ago #

    I'm developing a theme for one of our sites, which will be hosted off of WordPress MU with Buddy Press. In the sidebar.php file, there are certain elements which we only want present on the homepage, while there are others we want on other pages. Figuring this would be relatively simple, I have the following file:

    <?php do_action( 'bp_before_blog_sidebar' ) ?>
    
    <div id="sidebar">
      <?php do_action( 'bp_inside_before_blog_sidebar' );
            if( !function_exists('dynamic_sidebar') || !dynamic_sidebar('blog-sidebar') ) {
                echo 'Please login and put some widgets here.';
            }
            do_action( 'bp_inside_after_blog_sidebar' );
    
            if( is_front_page() ) {
    ?>
    <!-- HTML for front page -->
    <?php    } else { ?>
    <!-- HTML for other pages -->
    <?php } 
    
    do_action( 'bp_after_blog_sidebar' );
    ?>

    However, both on the front page of the blog AND on all other pages, I get the <!-- HTML for other pages -->. I have tried is_home() and is_front_page(). They both return false, even when I am clearly on the homepage of the site.

    Is there any guidance on this? Am I doing it right? Clearly I must not be, since I'm getting the same results on all the pages.

About this Topic

  • Started 15 years ago by greg.hellings