Last active
November 12, 2018 16:48
-
-
Save davidmaneuver/876213b3b138a1b3df7616cdabf50e84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get context. | |
**/ | |
$context = Timber::get_context(); | |
/** | |
* Retrieve current language. | |
**/ | |
$locale = get_bloginfo('language'); | |
$context['lang'] = substr($locale, 0, 2); | |
/** | |
* Load in defined menus. | |
**/ | |
if ($locs = get_nav_menu_locations()) { | |
foreach ($locs as $name => $id) { | |
$context['menus'][$name] = new TimberMenu($id); | |
} | |
} | |
/** | |
* Retrieve posts. | |
**/ | |
if (is_singular()) { | |
$context['post'] = \Timber::get_post(); | |
$context['is_preview'] = is_preview(); | |
} else { | |
$context['posts'] = \Timber::get_posts(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment