ThemeShaper Forums » Thematic

[closed]

Why does Wordpress doesn't recognize is_page() and is_single()?

(5 posts)
  • Started 9 years ago by adred
  • Latest reply from adred
  • This topic is resolved

Tags:

  1. adred
    Member

    I have these functions below that remove thematic_navigation_below and thematic_comments_template respectively.

    //Remove nav_below when is_single.
    if( is_single() ) {
    function remove_navbelow() {
    remove_action('thematic_navigation_below', 'thematic_nav_below', 2);
    }
    add_action('init', 'remove_navbelow');
    }

    ////Remove comments_template when is_page.
    if( is_page() ) {
    function remove_comments_template() {
    remove_action('thematic_comments_template','thematic_include_comments',5);
    }
    add_action('init', 'remove_comments_template');
    }

    How come they're not working when I wrap them with is_x() wp functions? If I place them outside they work perfectly. Any idea pls?

    Posted 9 years ago #
  2. i had some issues with is_page_template() b/c init was apparently too early in the process... ie... at the point when init is called the code didn't KNOW yet, what template was being used. i got around that by adding my code to the template_redirect hook. no idea if it is the same problem, but give that a try.

    //Remove nav_below when is_single.
    if( is_single() ) {
    function remove_navbelow() {
    remove_action('thematic_navigation_below', 'thematic_nav_below', 2);
    }
    add_action('template_redirect', 'remove_navbelow');
    }
    Posted 9 years ago #
  3. adred
    Member

    Unfortunately it didn't work for me. I am new to wp hooks, is there a standard way about when exactly are we going to remove a particular action? I mean just like what you said, maybe my code just doesn't have the right timing when adding the action. I guess my problem is very typical, I don't understand why no one here knows the correct solution?

    Posted 9 years ago #
  4. hmmm i was just telling someone else in the last day or 2 about how your conditions need to be inside the function, so i can't believe i didn't notice that here.

    it isn't that WP doesn't recognize is_single.... your PHP is wrong

    function remove_navbelow() {
    if( is_single() ) {
    remove_action('thematic_navigation_below', 'thematic_nav_below', 2);
    }}
    add_action('template_redirect', 'remove_navbelow');

    tested and working for me.

    Posted 9 years ago #
  5. adred
    Member

    That worked! Thanks a lot! :-)

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.