 
	
		
		
		
		
			
- 
		AuthorPosts
- 
		
			
				
June 27, 2016 at 3:05 pm #653798Hi guys, 
 So I used your documentation to create a custom widget for the header section: http://kriesi.at/documentation/enfold/adding-a-widget-area-to-the-header/The code used (from documentation): add_action( 'ava_after_main_menu', 'enfold_customization_header_widget_area' ); function enfold_customization_header_widget_area() { dynamic_sidebar( 'header' ); }Works like a charm, thank you! However, I need the header/widget to only show on the front page. 
 The reason is this: the custom header widget contains a small digital clock which should only be visible on the Home page, and not all sub-pages.I guess I need to add some code to the above code section, but I have no idea what the code/function is to only show the custom header widget on the front page? I could imagine it to be some kind of an if-function that states the condition “if page === ‘Home’, then show header” or something, but what would you suggest? Thanks! Love your product and services! - 
		This topic was modified 9 years, 4 months ago by Dbertelsen. 
 June 27, 2016 at 4:29 pm #653865Hey Dbertelsen, try to add WordPress’ is_page function to the code from documentation: https://developer.wordpress.org/reference/functions/is_page/ Best regards, 
 AndyJune 27, 2016 at 5:17 pm #653885Hi Andy, 
 Thanks. I can’t seem to get it to work though. The custom header widget/clock is not showing at all now.The slug of my home/front page is just ‘home’, and I’m using this code: if ( is_page( 'home' )) { add_action( 'ava_after_main_menu', 'enfold_customization_header_widget_area' ); function enfold_customization_header_widget_area() { dynamic_sidebar( 'header' ); }; }I have added the code to the same functions.php as the code for the custom header widget (the functions.php file for the child theme). - 
		This reply was modified 9 years, 4 months ago by Dbertelsen. 
 June 27, 2016 at 7:45 pm #653937Hey! Please change your code as the following if ( is_page( 'home' )) { add_action( 'ava_after_main_menu', 'enfold_customization_header_widget_area' ); function enfold_customization_header_widget_area() { dynamic_sidebar( 'header' ); } }If I catched the error correctly, you must be ok. Let me know if I have missed something. Regards, 
 BasilisJune 27, 2016 at 8:13 pm #653946Hmmm.. no, still not working. The header widget is not showing at all now. I have this code in my Quick CSS field. Would that have something to say? The clock/widget is located to the right side, just below the logo/menu section/border. /* Header clock CSS */ #header .widget { left: 91%; padding-top: 0px; position: absolute; top: 80%; padding-bottom: 0px; z-index: 1; }- 
		This reply was modified 9 years, 4 months ago by Dbertelsen. 
 June 30, 2016 at 12:06 pm #655227Hi, Please use the code as following add_action( 'ava_after_main_menu', 'enfold_customization_header_widget_area' ); function enfold_customization_header_widget_area() { if(is_home()){ dynamic_sidebar( 'header' ); } }Best regards, 
 YigitJune 30, 2016 at 8:48 pm #655467Hi Yigit, For some reason the is_home() command doesn’t seem to do the trick. I tried with is_front_page() instead and it works! So the final, working code is: add_action( 'ava_after_main_menu', 'enfold_customization_header_widget_area' ); function enfold_customization_header_widget_area() { if(is_front_page()){ dynamic_sidebar( 'header' ); } }Not sure why the is_home() command didn’t work. Probably because it doesn’t recognize my front page as home page. 
 Either way it works now.Thank you so much for your awesome support. You guys rock! Daniel 
- 
		This topic was modified 9 years, 4 months ago by 
- 
		AuthorPosts
- The topic ‘How to: Show custom header widget only on Home page?’ is closed to new replies.
