Skip to content

[From WP.org] Menu link outputs post id ( #276

@jarednova

Description

@jarednova

This came in from WP.org forums:

https://wordpress.org/support/topic/menu-link-outputs-post-id?replies=1

Hello!

First of all thanks for this library. I just started 1 week ago my first wordpress project. I was using silverstripe before. Timber offers great structure and functionality!

My question: Why when I use TimberMenu I receive always numeric id from post as link. I'll like to use the permalink like: http://mysite.domain/my-slug. Instead I receive always id like for example http://mysite.domain/2.

Here is the twig code:

<ul class="nav navbar-nav">
     {% for item in menu.get_items %}
     <!-- class active for active -->
     <li {% if item.get_children %}class="dropdown"{% endif %}>
          {% if item.get_children %}
               <a href="{{item.link}}">{{item.title}}<span class="caret"></span></a>
               <ul class="dropdown-menu" role="menu">
               {% for child in item.get_children %}
                    <li><a href="{{child.link}}">{{child.title}}</a></li>
               {% endfor %}
          {% else %}
               <a href="{{item.url}}">{{item.title}}</a>
          {% endif %}
     {% endfor %}

Is there something I'm missing in the documentation?
Thanks in advance!!

dani

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-investigationWe've got all the info, now someone needs to look into this to figure out what's going on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions