Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #496451

    I cannot seem to get is_page to work inside of functions.php. My code is here:

    wp_reset_query();
    if(is_page(‘forums’)) {
    add_action( ‘ava_after_main_menu’, ‘enfold_customization_header_widget_area’ );
    function enfold_customization_header_widget_area() {
    dynamic_sidebar( ‘SearchFilter’ );
    }
    } else {
    global $post;
    $post_slug=$post->post_name;
    echo $post_slug;
    }

    I have tried with an ID value as well, and that doesn’t work either. It always falls to the second conditional, and the echo there doesn’t print anything. Is the page not recognized at this point in the functions file?

    If I change the original statement to: if(! is_page(‘forums’)), then it does invoke the first section.

    Thanks for the help.

    #496568

    Hi fsefco!

    You probably need to add it inside the function.

    add_action( ‘ava_after_main_menu’, ‘enfold_customization_header_widget_area’ );
    function enfold_customization_header_widget_area() {
    if(is_page(‘forums’)) {
    

    Cheers!
    Elliott

    #496574

    hmmm, still doesn’t work unfortunately….

    wp_reset_query();
    add_action( ‘ava_after_main_menu’, ‘enfold_customization_header_widget_area’ );
    function enfold_customization_header_widget_area() {
    if(is_page(25)) {
    dynamic_sidebar( ‘SearchFilter’ );
    }
    }

    #496682

    I am now unable to access my site backend.

    #496688

    I renamed Enfold Child theme folder and then renamed it back and it seems to be ok now.

    #497189

    Hey!

    Are you just trying to get a widget area in your header? http://kriesi.at/documentation/enfold/adding-a-widget-area-to-the-header/

    Why are you resetting the query? What’s the full code your using?

    Best regards,
    Elliott

    #497199

    I have the widget in my header. It is the text widget and it displays an image. I am trying to get it to display only on certain pages. I added the reset because I was trying anything and everything to get it to work. It doesn’t seem to know what the page is at this point in the functions.php file. So specifying an if statement with is_page has no effect.

    #497230

    BTW, I fixed the login issue. Please disregard that.
    In my functions.php file, I added the code:

    $id = get_the_ID();
    echo ‘here is the number: ‘ . $id;

    Should this return the page ID? It returns nothing at the moment.

    #497353

    I got it to work. As you mentioned you have to get the ID from within a function inside functions.php. I used the below code and it works. Thanks for the help and support. This can be marked resolved.

    add_action( ‘ava_after_main_menu’, ‘enfold_customization_header_widget_area’ );
    function enfold_customization_header_widget_area() {

    global $post;
    $p = $post->ID;
    if($p == 25) {
    dynamic_sidebar( ‘SearchFilter’ );
    }
    }

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘is_page not working in functions.php’ is closed to new replies.