-
AuthorPosts
-
September 1, 2015 at 3:34 pm #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.
September 1, 2015 at 5:23 pm #496568Hi 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!
ElliottSeptember 1, 2015 at 5:35 pm #496574hmmm, 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’ );
}
}September 1, 2015 at 7:47 pm #496682I am now unable to access my site backend.
September 1, 2015 at 7:55 pm #496688I renamed Enfold Child theme folder and then renamed it back and it seems to be ok now.
September 2, 2015 at 3:38 pm #497189Hey!
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,
ElliottSeptember 2, 2015 at 3:45 pm #497199I 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.
September 2, 2015 at 4:16 pm #497230BTW, 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.
September 2, 2015 at 8:03 pm #497353I 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’ );
}
} -
AuthorPosts
- The topic ‘is_page not working in functions.php’ is closed to new replies.