-
-
Save cre8tivediva/c1e1e249cee41d4494e7eb70cc4d509d to your computer and use it in GitHub Desktop.
Add Widget to Primary Nav - Genesis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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( '' ); | |
} | |
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