askdesign
6/10/2015 - 12:36 AM

How to add a widget before the post content for a specific category in Genesis

tutorial

http://chantalvanderlaan.com/how-to-add-a-widget-before-the-post-content-for-a-specific-category-in-genesis/
//* step 1 - Register Advanced tutorial warning box widget area
genesis_register_sidebar( array(
	'id'            => 'warning-before-post',
	'name'          => __( 'Advanced Tutorial Warning', 'parallax' ),
	'description'   => __( 'This is a widget area that can be placed before the post', 'parallax' ),
) );
//*** step 2 - Hook Advanced Tutorial warning widget area before post content
add_action( 'genesis_before_entry_content', 'tutorial_genesis_box');
	function tutorial_genesis_box() {
       if ( is_home() ) {
		return;
       }
		
	   if (is_archive()){
	   return;
	}
	elseif (in_category('genesis-tutorials')){

		genesis_widget_area( 'warning-before-post', array(
			'before' => '<div class="genesis-box-tutorial">',
			'after' => '</div>',
	) );
}
}
/*--- step 3 - Then I can style it with some basic CSS: ---*/
.genesis-box-tutorial {
  background: none repeat scroll 0 0 #e6ebd8;
  border: 1px dashed #acbd7e;
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 20px;
  padding: 10px;
}

/*--- All done! Of course your WordPress Conditionals may be a little different so you’ll have to customize for your needs. Same goes for your CSS. ---*/
Final step is to add content to my widget:
	

The following tutorial is based on the Genesis Framework and may be advanced for some readers. My tutorials are based on my own experiences in learning Genesis so I would love some feedback. If you are not familiar with PHP code, I do not recommend making any changes to your functions.php (unless of course you have a back-up of your functions.php and you know how to restore it).

If you're new to Wordpress, please take a moment to check out my very own Step by Step Wordpress for Beginners Guide