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 | |
/** | |
* Add description to menu. | |
* | |
* Adjust description location as needed. | |
* | |
* @since 1.0.0 | |
* @param string $item_output | |
* @param object $item | |
* @return string | |
*/ | |
function ja_add_menu_description( $item_output, $item ) { | |
if ( !empty( $item->post_content ) ) { | |
$new_output = '<span class="description">' . $item->post_content . '</span>' . $item->title; | |
$item_output = str_replace( $item->title, $new_output, $item_output ); | |
} | |
return $item_output; | |
} | |
add_filter( 'walker_nav_menu_start_el', 'ja_add_menu_description', 10, 2 ); |
Questions, comments, or suggestion for improvement? Leave a comment on the GitHub Gist page.