ThemeShaper Forums » Thematic

[closed]

Need to get rid of navigation on home page only

(13 posts)
  • Started 10 years ago by erikvlie
  • Latest reply from tarpontech
  • This topic is resolved
  1. Hi everybody,

    I can't work it out and I thought I could style it out, but when I do, all navigation also becomes invisible on category pages, and it should only disappear on the home page.

    I can't figure out why the following code doesn't work:

    function remove_thematic_navigation_below() {
    	if (is_home() || is_frontpage() );{
    	remove_action ('thematic_content', 'thematic_navigation_below');
    	}
    }
    	add_action('thematic_content','remove_thematic_navigation_below');

    Also, the below code doesn't work:

    function remove_thematic_navigation_above() {
    	remove_action ('thematic_content', 'thematic_navigation_above');
    	}
    	add_action('thematic_content','remove_thematic_navigation_above');

    I also tried replacing "thematic_content" with "init" in the add_action part, but that makes the page go white. The statement as is turns off sidebars and footer.

    Can anyone help me?

    Posted 10 years ago #
  2. I'm sure I found this here on the forum somewhere, don't remember where, and I don't remember why you have to call wp instead of init.

    So..I don't have all the answers...but, i know this works (cause I actually tested this time). :)

    '
    function remove_nav_below() {
    if (is_front_page() || is_home()) {

    remove_action('thematic_navigation_below','thematic_nav_below', 2);
    }
    }
    add_action('wp', 'remove_nav_below');

    '

    Posted 10 years ago #
  3. Thanks for your code, but it still removes navigation from ALL pages, including category pages, and on those pages I want navigation to stay.

    I even tried to add
    && !is_category()
    to your code, but that too doesn't help...

    Posted 10 years ago #
  4. function remove_nav_below() {
    if (is_front_page() || is_home()) {
    
    remove_action('thematic_navigation_below','thematic_nav_below', 2);
    }
    else {} // or alternatively you could do else (is_category()){}
    }
    add_action('wp', 'remove_nav_below');
    Posted 10 years ago #
  5. That won't work either. Perhaps this is a bug in 0.9.7.3?

    Posted 10 years ago #
  6. its not a bug, we just don't have it right yet. I'll load up a default child theme and poke at this for a moment.

    Posted 10 years ago #
  7. is this page live that I can look at it?

    I just used:

    function remove_nav_below() {
    if (is_front_page() || is_home()) {
    
    remove_action('thematic_navigation_below','thematic_nav_below', 2);
    }
    }
    add_action('wp', 'remove_nav_below');

    ...and it worked to remove navigation from main page but left it on category archives. Either I'm misunderstanding, or you have something going on that I'm not aware of.

    Posted 10 years ago #
  8. Probably some plugin conflicting with the code, because its behaviour never changes. I have found another way around it. Thanks for all your help and advice.

    Posted 10 years ago #
  9. Hi-

    Normally when you wand to use the remove_action() function with thematic, you'll wrap it in a function and hook it to init

    But when you are conditionally removing an action using template tags you'll need to hook your function into WordPress at a point when the template to be used has been determined. The hook you want is template_redirect

    You also need to include the "priority" of the action. In this case the "2".

    function remove_thematic_navigation_below() {
    	if (is_home() || is_front_page()) {
    		remove_action('thematic_navigation_below', 'thematic_nav_below', 2);
    	}
    }
    add_action('template_redirect','remove_thematic_navigation_below');

    -Gene

    Posted 10 years ago #
  10. Thanks Gene! Learning something new every day! Retaining it all is the hard part.

    If you, or anyone happens to see this, I have a basic comprehension of what $priority does, as in your example above where you used a priority of 2, but I don't have enough grasp of how you determine what priority to use in a given circumstance.

    I've done a bit of googling on the subject, but between the codex and a few blog posts, I've yet to stumble upon a decent write-up to help provide some guide-posts.

    Anyone have any bookmarks they could share on the subject of priority?

    Posted 10 years ago #
  11. Priority is like a queue with functions lining up in a specific order for execution.

    Here are the best two links that really define what is happening here:

    http://codex.wordpress.org/Function_Reference/add_action
    http://codex.wordpress.org/Function_Reference/remove_action

    When you add_action to an action hook(the tag parameter) without specifying the priority parameter it is given a default priority of ten. The same is true for remove_action in terms of the default priority.

    Thematic makes extensive use of actions that are given a specific priority. If you look through thematic>library>extensions you will see many instances of "add_action" with a specific priority.

    In order to effectively use the remove_action function, you must include the priority with which the original function was assigned using the add_action function.

    Posted 10 years ago #
  12. It's magic! Thanks for the help. I read the user guide again and the Codex, but it's very hard to know when the use each different hook... When explained, it seems logical, but when I have to apply this to new circumstances, I'm afraid I will be making other, equally stupid mistakes.

    Posted 10 years ago #
  13. Thanks again Gene. I had suspected, but had never fully understood the significant role priority plays in Thematic. Now I just have to go through a few function.php files and make some little changes...

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.