Now, creating Facebook tabs using Facebook Tab Manager (see previous post), only allowed me to create "pages." However, I wanted a menu system for my Facebook tabs to be controlled within my WordPress site, so instead of creating a template for Facebook Tab Manager that included a navigation system that connected all my Facebook Tabs, I created a navigation shortcode for users to insert their desired navigation menu, created in WordPress's custom menus and have further control. Since Facebook Tabs Posts are their own custom post type, creating a menu system for them is quite easy.
How the Genesis Nav Shortcode Works
To use the code, insert [genesis_nav] into your post. It takes a few different arguments:
- container_class: adds a custom class to the wrap class
- menu: the menu that is desired; accepts (matching in order) id, slug, name
- custom_class: adds a custom class to the menu system, pulls superfish option from Genesis theme settings
The default output code is:
[php]
<div id="nav"><div class="wrap">WP_NAV_MENU</div></div>
[/php]
Sample:
[genesis_nav menu=39 custom_class='fun']
Code/Download
You can download the code [download id="7"], insert into your child theme folder, and include the following in your functions.php file.
[php]require_once(STYLESHEETPATH.'/genesis_nav_shortcode.php');[/php]
Or, here's the entire code that can be added to functions.php.
[php]
<?php
//nav shortcode
add_shortcode('genesis_nav', 'genesis_nav_shortcode');
function genesis_nav_shortcode( $atts ) {
$menu_setting = genesis_get_option('nav_superfish') ? 'nav superfish' : 'nav';
$defaults = array(
'container' => '',
'container_class' => '',
'menu' => '',
'menu_class'=> $menu_setting,
'custom_class'=>'',
'echo'=>0
);
$atts = shortcode_atts( $defaults, $atts );
$classes = $menu_setting;
$classes .= ' '. $atts['custom_class'];
$nav = wp_nav_menu(array(
'container' => $atts['container'],
'menu' => $atts['menu'],
'menu_class' => $classes,
'echo' => $atts['echo']
));
echo '<div id="nav"><div class="wrap'.$atts['container_class'].'">' . $nav . '</div></div>';
}
?>
[/php]