• Resolved avihai1

    (@avihai1)


    hey, i tried to add an img before the link in the menu with “before” attribute but for some reason it doesnt add it (link_before works, but its in the <a> tag).

    anyway, here is the code:

    <?php wp_nav_menu(
    	array(
    	'container_class' => 'navi',
    	'menu_class' => 'navi',
    	'before' => '<img src="style/images/tree.png" alt="sds" />',
    	'theme_location' => 'primary'
    	)
    );
    ?>

Viewing 6 replies - 1 through 6 (of 6 total)
  • My guess is that the before parameter is passed through a strip_tags function. So it can only be used for plain text – not markup.

    Thread Starter avihai1

    (@avihai1)

    I already tried adding a plain text but it doesnt work either.
    maybe something with functions.php?

    register_nav_menus( array(
    		'primary' => __( 'Main Navigation', 'shita' ),
    	) );

    Try, ‘link_before’ and ‘link_after’

    <?php wp_nav_menu(
    	array(
    	'container_class' => 'navi',
    	'menu_class' => 'navi',
    	'link_before' => '<img src="style/images/tree.png" alt="sds" />',
    	'theme_location' => 'primary'
    	)
    );
    ?>

    Another could be to style the title in the style.css, and add the element in the menu call:
    'title_li' => '<div class="title-left"></div><div class="title-right"></div>',

    Just read your post again and seen you already tried ‘link_before’, eyes are just quicker than the brain!

    HTH

    David

    Thread Starter avihai1

    (@avihai1)

    well, i decided to use the link_before.
    thanks a lot for your help!

    This issue shouldn’t be closed. Both the before and after attributes seem to be broken for wp_nav_menu. Please either fix the attributes or change the documentation since it’s confusing to users not familiar with WP3.

    Thanks!

    The same here. Before / After does not work with wp_nav_menu.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘wp_nav_menu before doesnt work’ is closed to new replies.