-
-
Save senlin/5145602 to your computer and use it in GitHub Desktop.
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
Adding a Foundation 3 Nav Bar to WordPress | |
This code should be added to the WordPress functions.php file. | |
Call the menu in your theme by using <?php foundation_nav_bar(); ?> | |
Setup a menu in WordPress admin under Appearance > Menus | |
Note: the function main_nav_fb() could be used to echo an error instead of wp_list_pages() as a menu. Another option is to set 'fallback_cb' => false. If you choose to not use wp_list_pages() the page_walker is not needed. | |
Foundation 3 Navigation Docs: http://foundation.zurb.com/old-docs/f3/navigation.php |
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 | |
/* | |
Customize the output of page list for Foundation nav classes in main_nav_fb | |
*/ | |
class page_walker extends Walker_Page { | |
function start_el(&$output, $page, $depth, $args, $current_page) { | |
$item_html = ''; | |
parent::start_el($item_html, $page, $depth, $args, $current_page); | |
$css_class = array('page_item', 'page-item-'.$page->ID); | |
if ( $args['has_children'] ) { | |
$css_class[] = 'has-flyout'; | |
} | |
$css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); | |
$item_html = '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>'; | |
$output .= $item_html; | |
} | |
function start_lvl( &$output, $depth = 0, $args = array() ) { | |
$output .= "\n<a href=\"#\" class=\"flyout-toggle\"><span> </span></a><ul class=\"flyout $this->flyout_dir\">\n"; | |
} | |
} // end page walker | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment