WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adding a div to external links in custom nav (3 posts)

  1. scifizoe
    Member
    Posted 1 year ago #

    I want to add an image that is to the right of a link in the custom menus if they have an external link (_blank). I've tried a few things with the Walker but not having much success. I have multiple menus and trying to make this as easy as a 'click' for the end user. Thanks much!

    Added this after the walker

    wp_nav_menu( array('menu_class' => 'openLink',
                 'link_after' => '<div class="openLinkImg"></div>',
                 'walker'=> new MFC_Walker_Nav_Menu()
    ) );

    I had added 'openLink' to use as a trigger.

  2. scifizoe
    Member
    Posted 1 year ago #

    I believe what I am looking for is some sort of conditional if it's an external link or if it has the 'openLink' class set. I realize that the above is not correct. Can you add a conditional like that?

  3. scifizoe
    Member
    Posted 1 year ago #

    Ah! very cool.. got it figured out using the Walker and setting a conditional if the target item is _blank! Worked like a charm.

Topic Closed

This topic has been closed to new replies.

About this Topic