Abbreviate Month in Primary Navigation Bar – Enterprise

Community Forums Forums Design Tips and Tricks Abbreviate Month in Primary Navigation Bar – Enterprise

This topic is: not resolved

This topic contains 6 replies, has 2 voices, and was last updated by  Gary Jones 4 months, 4 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #64291

    barryo
    Participant
    Post count: 6

    Can anyone tell me how to abbreviate the date in the Primary Navigation Bar?

    Thanks in advance!

    http://www.survivalsystemsinternational.com/
    #67543

    Gary Jones
    Moderator
    Post count: 622

    Try:

    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   <a href="http://www.studiopress.com/forums/topic/abbreviate-month-in-primary-navigation-bar-enterprise/" rel="nofollow">http://www.studiopress.com/forums/topic/abbreviate-month-in-primary-navigation-bar-enterprise/</a>
     *
     * @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 <a href="http://php.net/manual/en/function.date.php" rel="nofollow">http://php.net/manual/en/function.date.php</a>
    
    	return preg_replace(
    		'#\<li class="right date"\>(.*)\</li\>#',
    		'<li class="right date">' . date_i18n( $format ) . '</li>',
    		$menu
    	);
    }
    

    Changes in Genesis 2.0 – the ultimate guide to every single change in Genesis Framework 2.0, 2.0.1 and 2.0.2 (all 159 of them!) | @GaryJ

    #71697

    barryo
    Participant
    Post count: 6

    Thanks for the reply Gary. I just now saw it or I would’ve responded earlier.

    What file do I add your code to?

    #71699

    Gary Jones
    Moderator
    Post count: 622

    It goes into your child theme functions.php file.


    Changes in Genesis 2.0 – the ultimate guide to every single change in Genesis Framework 2.0, 2.0.1 and 2.0.2 (all 159 of them!) | @GaryJ

    #71704

    barryo
    Participant
    Post count: 6

    Awesome. Thanks.

    #71711

    barryo
    Participant
    Post count: 6

    When adding the code to the functions.php file I get an error that the call “add_filter” is not valid.

    What might I be missing?

    #73909

    Gary Jones
    Moderator
    Post count: 622

    Can you paste your functions.php file (at pastebin or as a Gist and link here)?


    Changes in Genesis 2.0 – the ultimate guide to every single change in Genesis Framework 2.0, 2.0.1 and 2.0.2 (all 159 of them!) | @GaryJ

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.