Skip to content

Instantly share code, notes, and snippets.

@cdils
Forked from srikat/functions.php
Last active May 18, 2018 01:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cdils/11381240 to your computer and use it in GitHub Desktop.
Save cdils/11381240 to your computer and use it in GitHub Desktop.
Add widget area (with Simple Socian Icons) to primary navigation.
<?php //remove this line
// Register the widget area
genesis_register_sidebar( array(
'id' => 'nav-social-menu',
'name' => __( 'Nav Social Menu', 'your-theme-slug' ),
'description' => __( 'This is the nav social menu section.', 'your-theme-slug' ),
) );
add_filter( 'wp_nav_menu_items', 'sws_social_icons', 10, 2 );
function sws_social_icons($menu, $args) {
$args = (array)$args;
if ( 'primary' !== $args['theme_location'] ) {
return $menu;
}
// start to buffer the output
ob_start();
// wrap the menu in a list item, otherwise it throws a validation error
echo '<li class="menu-item">';
genesis_widget_area('nav-social-menu');
echo '</li>';
$social = ob_get_clean(); //
return $menu . $social;
}
.genesis-nav-menu .widget {
float: right;
}
.genesis-nav-menu .simple-social-icons ul li {
margin-bottom: 0 !important;
margin-top: 0.7rem !important;
}
.genesis-nav-menu .widget-area {
float: right;
padding-top: 2.2rem;
}
.genesis-nav-menu .widget-area {
float: right;
padding-top: 1.5rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment