Ad
Getting The "Open Link In A New Tab" Property From A WordPress Menu Item
In a typical menu item loop is there something like item.target
when setting the 'Open link in a new tab' option?
I see the issue has been brought up before and is now available in Timber V2 but is there a way to get it working in available in Timber version 1.0?
{% for item in menu.items %}
<li>
<a href="{{ item.link }}" target="{{ item.target }}">{{ item.title }}</a>
</li>
{% endfor %}
Ad
Answer
The below works in Timber v1.19.1
Twig v1.42.5
{% for item in menu.items %}
<li>
<a href="{{ item.link }}"
target="{{ item.meta( '_menu_item_target' ) ? item.meta( '_menu_item_target' ) : '_self' }}">
{{ item.title }}
</a>
</li>
{% endfor %}
Ad
source: stackoverflow.com
Related Questions
- → CORS missmatch because of http
- → Building sitemap for 2 wordpress install under 1 domain
- → How to remove empty elements after class?(jQuery)
- → Get width of an element and apply to another relative to the first one?
- → How to remove caption p class from wordpress?
- → 301 Redirection from no-www to www in wordpress
- → Laravel 5 routing using prefix
- → WordPress - Header position Top, Left &Right
- → how to add rel=nofollow to some specific external links in wordpress
- → octobercms install error: database is not empty?
- → How to edit the index page of wordpress theme?
- → How to select a Post Type (Wordpress) to pass a filter in head?
- → What sort of URL structure should be used to display AMP HTML vs vanilla HTML
Ad