ThemeShaper Forums » Thematic


is_home is_front_page issues

(8 posts)
  • Started 9 years ago by EricH
  • Latest reply from EricH
  • This topic is not resolved
  1. I'm having issues with is_home and is_front_page. I've created a custom home page(home.php) for a theme that adds some widget areas to the home page and removes the sidebars. I'm using if (is_front_page()) to remove sidebars and add extra widgets. I've also tried (is_home()). My problem is that it removed the sidebar and adds the widgets to the blog as well as the custom home page.
    Anyone else having this problem? I know I ran into this before, and had a solution, I just can't remember what it was.
    I'm using the latest svn version of thematic.
    Thanks in advance.

    Posted 9 years ago #
  2. is_front_page should work. does it not? is_home() is actually misleading... i wish it were is_blog() instead since it actually refers to whatever page your blog is on. you could also try is_page_template('home.php')

    Posted 9 years ago #
  3. Thanks helgatheviking for the feedback. is_front_page is definitely not working. is_page_template() doesn't work ether. I suppose I could have people make a page called home and use a custom page template(rather then home.php). It's just another step that I really didn't want users to have do. If you want to take a look at what i've got going on give me your email and I'll send you the child theme that im working on.

    Posted 9 years ago #
  4. what about is_page() or is_page('home') or is_page('45'). if none of those work then you've got some kind of serious problem in how you are setting up your IF (or also more likely WHEN it gets executed). can you post the relevant sections?

    Posted 9 years ago #
  5. I've removed all of my custom code from home.php and everything in the functions.php except this.

    //remove sidebar on certain pages
    function remove_sidebar() {
    // We test if we are on the page 'Forum'
    if (is_front_page()) {
    // Yes, we are .. now we switch off the sidebar
    return FALSE;
    }else {
    // we are not .. we leave the switch on
    return TRUE;
    // Connect the filter to thematic_sidebar()
    add_filter('thematic_sidebar', 'remove_sidebar');

    Here is exactly what I'm doing. It should be pretty easy to reproduce if it is indeed a problem.
    I'm on my localhost running the latest version of Wordpress and Thematic. I've created a custom home.php file which is pretty much the same code that is in single.php except i've removed the php in the content area(for testing this, I've also removed all of my custom code).
    I've created a page called blog and I'm using the new blog template.
    I've tried everything I can think of including a bunch of different if is_ && !is_ .
    I'm going to put it on a server tonight just to make sure it isn't something with my localhost. I'll add a link when it's up.
    Thanks again for your help.

    Posted 9 years ago #
  6. I've got it live here.

    Posted 9 years ago #
  7. Hey EricH,

    There is an easier way to make this happen. I've found that it is better to not use home.php in favor of having a page-template and then setting up a static page to be the home page in the admin screen.

    So all you need to so is make a template file, create a new page called home, assign the template to that page, then go to the Settings -> Reading and in there set the "home" page to be the one that is loaded as a static homepage.

    this way both is_home and is_front_page both work correctly.

    You could also deal with this totally with CSS by using the body_class() function in the body tag and then using only CSS selectors in this kinda way

    in header.php
    <body <?php body_class(); ?>>

    in the css
    body.home #sidebar {display:none}

    all the best

    Posted 9 years ago #
  8. Thanks andykillen for the suggestions. I know it can be done this way, I just think it's easier for someone new to wordpress to set it up the way I was trying. Oh well, I guess in the long run it's only one more step. Thematic takes care of adding the body class to the body, and it's so easy to remove sidebars with thematic I wouldn't recommend using css to hide them.
    Thanks again

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.