Skip to content

Instantly share code, notes, and snippets.

@luisfelipe-dev
Created May 16, 2017 18:58
Show Gist options
  • Select an option

  • Save luisfelipe-dev/609d704f2b74bbf71029389ef6069859 to your computer and use it in GitHub Desktop.

Select an option

Save luisfelipe-dev/609d704f2b74bbf71029389ef6069859 to your computer and use it in GitHub Desktop.
Funções para criar menu no Wordpress
functions.php:
//MENU
class dwf_walker extends Walker {
var $db_fields = array(
'parent' => 'menu_item_parent',
'id' => 'db_id'
);
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$output .= sprintf( "\n<li class=\"list-item\"><a class='list-link' data-scroll data-options='{ 'easing': 'linear' }' href='%s'%s> %s</a></li>\n",
$item->url,
( $item->object_id === get_the_ID() ) ? ' class="current"' : '',
$item->title
);
}
}
register_nav_menus( array(
'header-menu' => __( 'Header Menu' ),
));
--------
header.php:
<ul class="offcanvas-list">
<?php wp_nav_menu(
array(
'items_wrap'=> '%3$s',
'walker' => new dwf_walker(),
'container'=> false,
'menu_class' => '',
'theme_location'=> 'extra-menu', //Aqui você coloca nome do menu principal,
'fallback_cb'=> false ,
));
?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment