WordPress.org

Forums

How to make link_after DYNAMIC? (2 posts)

  1. DeNiro
    Member
    Posted 4 years ago #

    Hi there once again! :)

    <?php wp_list_pages('link_after=<span>- This is an additional text</span>'); ?>

    The code above creates the full list of pages with links and there's an additional <span> next to each link, so it looks like that:

    • PAGE 1 - This is an additional text
    • PAGE 2 - This is an additional text
    • PAGE 3 - This is an additional text

    How to make it more dynamic?

    I'd love to have something like:

    • PAGE 1 - Additional text
    • PAGE 2 - Totally different additional text
    • PAGE 3 - And once again totally different text

    Any helping hand? :)

  2. thebiganswer
    Member
    Posted 4 years ago #

    Hello,

    I have a similar question which I hope will add to your initial question: how might I make the link_after conditional based on the tier/level?

    For example:

    <?php wp_nav_menu( array( 'theme_location' => 'my-nav', 'container_class' => 'menu-header', 'link_after' => ' >>' ) ); ?>

    The above will append " >>" to the menu item. That's ok for subitems with children, but it doesn't look very good on header items nor end-nodes, as it would negate the usefulness:

    Home >> About >> Etc >>
    Companies >> Etc sub item >>
    Acme Tech >> Etc sub item 2 >>
    Acme Global >>
    Team >>

    Ideally it would check if a child exists and only then append the " >>" and additionally it would start from level 1 (where level 0 is the header level), like so:

    Home About Etc
    Companies >> Etc sub item
    Acme Tech Etc sub item 2 >>
    Acme Global Etc sub item 2 (child)
    Team

    (I would have started a new thread but I found this one and I feel it is related - if not, please advise)

    I'd appreciate any commments and thanks to DeNiro for the initial posting.

Topic Closed

This topic has been closed to new replies.

About this Topic