Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #13041

    Hi,

    I would like to use HTML code within the WP3 menu manager description, but WordPress ignores this, when saving the menu.

    In detail:

    I need a line break

    Description line one< br />Description line two

    within the description text of the menu items.

    Anyone an idea? Thanks in advance!

    #77572

    Hey!

    Newer themes by Kriesi support this feature and basically it should be possible with a few menu handler code adjustments. I’ll ask him to look into it.

    Best regards,

    Peter

    #77573

    that would be great, thanks a lot, Dude!

    There seems to be a good chance, that Kriesi knows that, because I’ve found a similar question of him here:

    http://wordpress.org/support/topic/menu-description-html-code?replies=3

    As mentioned there in the answer to him, I added this

    remove_filter('nav_menu_description', 'strip_tags');

    to functions.php, but this was really a try&error method, because I have no knowledge at all of these things ;-) … it doesn’t work in that way.

    #77574

    I found this:

    http://wordpress.stackexchange.com/questions/36396/removing-strip-tags-not-working-on-nav-menu-description

    but unfortunately it sounds very “technical” to me. According to this advice, I’ve put in my theme’s function.php this code, that is mentioned at the bottom of this link:

    remove_filter('nav_menu_description', 'strip_tags');

    add_filter( 'wp_setup_nav_menu_item', 'cus_wp_setup_nav_menu_item' );

    function cus_wp_setup_nav_menu_item($menu_item) {

    $menu_item->description = apply_filters( 'nav_menu_description', $menu_item->post_content );

    return $menu_item;

    }

    The problem now is, that I can add in the Menue Manager my HTML (for example own line breaks), but now the HTML is shown as characters, see here:

    http://i50.tinypic.com/14vr3es.jpg

    But I haven’t right understood, whether some code needs to be in the header.php, too.

    #77575

    Hi colorit2,

    According to the link you posted above you will have to place code in header.php. Keep in mind I’ve never done this so I’m just going by the article you linked above so this may or may not work.

    Open you header.php and replace this:

    <!-- Navigation for Pages starts here -->
    <?php
    wp_nav_menu( array( 'menu' => 'First', 'menu_class' => 'nav', 'echo' => true,
    'fallback_cb' => '', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
    'depth' => 0, 'context' => 'frontend'));

    /* pre wp 3
    if(is_object($k_option['custom']['kriesi_menu_pages']))
    $k_option['custom']['kriesi_menu_pages']->display('Menu Manager Pages','show_basic');
    */
    ?>

    with this:

    <?php
    wp_nav_menu( array(
    'theme_location' => 'primary',
    'depth' => 0,
    'walker' => new description_walker())
    );
    ?>

    Again, I haven’t test this so I’m not sure if it will work or how well it work.

    Regards,

    Mya

    #77576

    thanks, Mya, that has no effect at all :-(

    As mentioned above, Kriesi for himself has asked exactly for this feature in a forum, found with Google:

    http://wordpress.org/support/topic/menu-description-html-code?replies=3

    so perhaps you or Peter could please ask him? Obviously he should know it, I guess :-)

    Thanks.

    #77577

    Well it was worth a shot. :) Kriesi’s been flagged to this thread.

    Regards,

    Mya

    #77578

    hey!

    line 30 of newscast/framework/classes you need to change from:


    $description = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';

    to


    $description = ! empty( $item->description ) ? '<span>'. $item->description .'</span>' : '';

    in addition you need to keep this code somewhere in your functions.php file:


    remove_filter('nav_menu_description', 'strip_tags');
    add_filter( 'wp_setup_nav_menu_item', 'cus_wp_setup_nav_menu_item' );
    function cus_wp_setup_nav_menu_item($menu_item) {
    $menu_item->description = apply_filters( 'nav_menu_description', $menu_item->post_content );
    return $menu_item;
    }

    #77579

    you made my day, Kriesi!!! It works like a charm! Thank you very, very much, I’ve tried so much without success, to get this!

    I have tried to add this possibility of HTML in menu descriptions in CORONA, too, but I had no success; could you please help me there, too?

    http://www.kriesi.at/support/topic/hmtl-in-main-menu-descriptions

    Thanks.

    #77580

    Hi,

    Just going to close this thread since this particular issue is now resolved.

    Regards,

    Mya

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘HTML within WP3 menu manager description’ is closed to new replies.