Skip to content

Instantly share code, notes, and snippets.

@cre8tivediva
Created January 19, 2021 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cre8tivediva/c1e1e249cee41d4494e7eb70cc4d509d to your computer and use it in GitHub Desktop.
Save cre8tivediva/c1e1e249cee41d4494e7eb70cc4d509d to your computer and use it in GitHub Desktop.
Add Widget to Primary Nav - Genesis
/* Primary Navigation Widget
------------------------------------------------*/
.genesis-nav-menu .widget-area {
float: right;
padding: 5px 15px 0 0;
}
@media only screen and (max-width : 1024px) {
.genesis-nav-menu .widget-area {
float: none;
padding: 15px 15px 0 15px
}
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Register Primary Navigation Widget
genesis_register_sidebar( array(
'id' => 'primary-nav-widget',
'name' => __( 'Primary Nav Widget', 'theme-name' ),
'description' => __( 'This widget appears in the primary-navigation.', 'theme-name' ),
) );
//* Add Primary Navigation Widget Areaa
add_filter( 'genesis_search_button_text', 'c8d_search_button_text' );
function c8d_search_button_text( $text ) {
return esc_attr( '&#xf179;' );
}
add_filter( 'genesis_nav_items', 'c8d_primary_nav_widget', 10, 2 );
add_filter( 'wp_nav_menu_items', 'c8d_primary_nav_widget', 10, 2 );
function c8d_primary_nav_widget($menu, $args) {
$args = (array)$args;
if ( 'primary' !== $args['theme_location'] )
return $menu;
ob_start();
genesis_widget_area('primary-nav-widget');
$social = ob_get_clean();
return $menu . $social;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment