Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save taricco/f68587934ac7a9db6f3c5d2a4fea6c96 to your computer and use it in GitHub Desktop.

Select an option

Save taricco/f68587934ac7a9db6f3c5d2a4fea6c96 to your computer and use it in GitHub Desktop.
//Custom Hook is: generate_bottom_of_primary_menu
add_shortcode('bottom_of_primary_menu_hook', function($atts){
ob_start();
$atts = shortcode_atts( array(
'hook_name' => 'bottom of menu'
), $atts, 'bottom_of_primary_menu_hook' );
do_action($atts['hook_name']);
return ob_get_clean();
});
add_filter( 'wp_nav_menu_items', 'prefix_add_div', 15, 2 );
function prefix_add_div( $items, $args ) {
if( $args->theme_location != 'primary' ) {
return $items;
}
$items .= '<li class="menu-item custom-menu-item">'.do_shortcode( '[bottom_of_primary_menu_hook hook_name="generate_bottom_of_primary_menu"]' ).'</li>'. $items;
return $items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment