Skip to content

Instantly share code, notes, and snippets.

@deckerweb
Forked from GaryJones/functions.php
Created October 19, 2013 09:58
Show Gist options
  • Save deckerweb/7053919 to your computer and use it in GitHub Desktop.
Save deckerweb/7053919 to your computer and use it in GitHub Desktop.
<?php
// Don't include the above
add_filter( 'wp_nav_menu_items', 'prefix_change_nav_date_format', 15, 2 );
/**
* Filter the Primary Navigation menu items in Genesis, to change the date format.
*
* @author Gary Jones
* @link http://www.studiopress.com/forums/topic/abbreviate-month-in-primary-navigation-bar-enterprise/
*
* @uses genesis_get_option() Get navigation extras settings.
*
* @param string $menu HTML string of list items.
* @param stdClass $args Menu arguments.
*
* @return string Amended HTML string of list items.
*/
function prefix_change_nav_date_format( $menu, stdClass $args ) {
if ( ! genesis_get_option( 'nav_extras' ) || 'primary' !== $args->theme_location )
return $menu;
if ( 'date' !== genesis_get_option( 'nav_extras' ) )
return $menu;
$format = 'j M Y'; // Change this, as per http://php.net/manual/en/function.date.php
return preg_replace(
'#\<li class="right date"\>(.*)\</li\>#',
'<li class="right date">' . date_i18n( $format ) . '</li>',
$menu
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment