Skip to content

Instantly share code, notes, and snippets.

View macder's full-sized avatar

Maciej Derulski macder

View GitHub Profile
@macder
macder / functions.php
Last active November 17, 2017 19:20
WordPress - Timber Menu: set an archive menu item to 'current' when location is a single post
<?php
/*
Suppose you have a custom content type called 'videos'
You have a menu item that points to the 'videos' archive page (http://yoursite.com/videos)
When on a single video page you want the 'videos' menu item to be styled as the current/active link
The following will make the Timber\MenuItem 'current' property to true on the archives menu item when on a single post
*/