Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Forked from anointed/finished.php
Created July 17, 2012 00:02
Show Gist options
  • Save pippinsplugins/3126005 to your computer and use it in GitHub Desktop.
Save pippinsplugins/3126005 to your computer and use it in GitHub Desktop.
Filter to apply a div before menu output
<?php
function tumble_menu( $args = array() ) {
/* Default arguments */
$defaults = array(
'container' => 'ul',
'menu_class' => 'nav',
'menu_id' => 'top_nav',
'theme_location' => 'top-menu',
'echo' => false,
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'depth' => 1,
'sort_column' => 'menu_order',
'walker' => ''
);
$defaults = apply_filters( 'tumble_nav_default_args', $defaults);
$args = wp_parse_args( $args, $defaults );
$main_menu = wp_nav_menu( $args );
}
function tumble_add_menu_wrapper($html, $begin, $end) {
// wrap our original HTML with the new tags
return $begin . $html . $end;
}
add_filter( 'tumble_menu_wrap', 'tumble_add_menu_wrapper', 10, 3 );
function tumble_do_menu_wrapper() {
$html = tumble_menu();
echo apply_filters( 'tumble_menu_wrap', $html, '<div class="menu-button">Menu</div>','' );
}
?>
@anointed
Copy link

updated the site with the new code, does the same thing, menu under ul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment