Created
January 21, 2013 03:09
-
-
Save GaryJones/4583367 to your computer and use it in GitHub Desktop.
Add date menu item to end of existing menu items (in primary location).
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 | |
| add_filter( 'wp_nav_menu_items', 'gmj_add_date_menu_item', 10, 2 ); | |
| /** | |
| * Add date menu item to end of existing menu items. | |
| * | |
| * @author Gary Jones | |
| * | |
| * @param string $items Menu items already converted to a string of markup. | |
| * @args stdClass $args Menu arguments. | |
| * | |
| * @return string Amended markup. | |
| */ | |
| function gmj_add_date_menu_item( $items, stdClass $args ) { | |
| // Limit to a certain menu location | |
| if ( 'primary' != $args->theme_location ) { | |
| return $items; | |
| } | |
| // Straight concatenation here. Could prepend, or do a regex replace to | |
| // insert the menu item elsewhere | |
| $items .= '<li class="menu-item right">' . date_i18n( get_option( 'date_format' ) ) . '</li>'; | |
| return $items; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment