Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 30, 2011 04:56

Revisions

  1. billerickson created this gist Oct 30, 2011.
    18 changes: 18 additions & 0 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    <?php
    /**
    * Add description to menu
    * @author Bill Erickson
    * @link http://www.billerickson.net/code/add-description-to-menu
    *
    * @param string $item_output
    * @param object $item
    * @return string modified item output
    */
    function be_add_description( $item_output, $item ) {
    $description = $item->post_content;
    if (' ' !== $description )
    return preg_replace( '/(<a.*?>[^<]*?)</', '$1' . '<span>' . $description . '</span><', $item_output);
    else
    return $item_output;
    }
    add_filter( 'walker_nav_menu_start_el', 'be_add_description', 10, 2 );