ThemeShaper Forums » Thematic

[closed]

removing navigation conditionally on home page

(5 posts)
  • Started 3 years ago by maren.m
  • Latest reply from maren.m
  • This topic is resolved
  1. maren.m
    Member

    Hi there,

    I have some seemingly simple code that I just can't get to work.
    I want to remove the navigation on a statice home page.

    Here is my code:

    function remove_home_nav() {
        if (is_home() || is_front_page()) {
        	remove_action('thematic_header','thematic_access',9);
    	}
    }
    add_action('init','remove_home_nav');

    This should work, right? I've tried lots of little tweaking but I feel like I'm missing something here..

    Posted 3 years ago #
  2. unsure, maybe try hooking in a little later than init

    add_action('template_redirect','remove_home_nav');

    or maybe later still

    add_action('wp_head','remove_home_nav');

    Posted 3 years ago #
  3. maren.m
    Member

    Thanks! 'template_redirect' worked perfect.

    If you've got a second...could you tell me why, exactly, it needs to be 'template_redirect' rather than 'init'? I'm kind of confused and just curious about this.

    Posted 3 years ago #
  4. i "think" it is b/c init is called dead first thing. so sometimes WP doesn't know what type of page you are on and therefore all conditional logic fails b/c you have nothing to test against.

    but the template_redirect hook is literally where WP decides which file is needed to display the page... and therefore it knows what page you are on and you can at this point perform conditional logic such as is_home()

    hope that made sense.

    Posted 3 years ago #
  5. maren.m
    Member

    thanks! it does!

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.