Last active
December 22, 2015 04:48
-
-
Save michaelcarwile/6419381 to your computer and use it in GitHub Desktop.
Output/display WordPress nav descriptions on Genesis Theme
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 | |
// don't copy php tag | |
/* Inspired by: | |
http://www.wpstuffs.com/add-menu-description-in-genesis/ | |
http://www.billerickson.net/genesis-quick-tips/ | |
*/ | |
//* Display nav descriptions (div after text within anchor - <a href>"Menu Name"<div>"Description"</div></a>) | |
function add_description_nav( $item_output, $item ) { | |
$description = $item->post_content; | |
return preg_replace( '/(<a.*?>[^<]*?)</', '$1' . '<div>' . $description . '</div><', $item_output); | |
} | |
add_filter( 'walker_nav_menu_start_el', 'add_description_nav', 10, 2 ); | |
// * SECOND OPTION - ONLY CHOOSE ABOVE OR BELOW CODE | |
//* Display nav descriptions (div before anchor - <div>"Description"</div><a href>"Menu Name"</a>) | |
function add_description_nav( $item_output, $item ) { | |
$description = $item->post_content; | |
return preg_replace( '/(<a.*?>)/', '$1<div></div>', $item_output); | |
} | |
add_filter( 'walker_nav_menu_start_el', 'add_description_nav', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment