Reply To: hook before both sidebars

Home Forums Support hook before both sidebars Reply To: hook before both sidebars

Home Forums Support hook before both sidebars Reply To: hook before both sidebars

#204619
Tom
Lead Developer
Lead Developer

This part is how you create a widget area which will show up in “Appearance > Widgets”:

function alphabet_widgets_init() {

	register_sidebar( array(
		'name'          => 'Home right sidebar',
		'id'            => 'home_right_1',
		'before_widget' => '<aside id="%1$s" class="widget inner-padding %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => apply_filters( 'generate_start_widget_title', '<h4 class="widget-title">' ),
		'after_title'   => apply_filters( 'generate_start_widget_title', '<h4 class="widget-title">' ),
	) );

}
add_action( 'widgets_init', 'alphabet_widgets_init' );

Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

Then your code from above would look something like this:

add_action( 'generate_sidebars','generate_double_right_sidebar', 0 );
function generate_double_right_sidebar()
{
	?>
	<div class="widget-area grid-50 tablet-grid-50 grid-parent sidebar double-sidebar">
		<div class="inside-double-sidebar">
			<?php if ( is_active_sidebar( 'home_right_1' ) ) : ?>
				<?php dynamic_sidebar( 'home_right_1' ); ?>
			<?php endif; ?>
		</div>
	</div>
	<?php
}

Hope that helps out a bit 🙂