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 1 year, 9 months ago.

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

    barryo
    Participant

    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

    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( &#8216;nav_extras&#8217; ) || &#8216;primary&#8217; !== $args-&gt;theme_location )
    		return $menu;
    
    	if ( &#8216;date&#8217; !== genesis_get_option( &#8216;nav_extras&#8217; ) )
    		return $menu;
    
    	$format = &#8216;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(
    		&#8216;#\&lt;li class=&quot;right date&quot;\&gt;(.*)\&lt;/li\&gt;#&#8217;,
    		&#8216;&lt;li class=&quot;right date&quot;&gt;&#8217; . date_i18n( $format ) . &#8216;</li>&#8216;,
    		$menu
    	);
    }
    

    Changes in Genesis 2.1 – the ultimate guide to every single change in Genesis Framework 2.1, 2.1.1 and 2.1.2 (all 90 of them!) | @GaryJ

    #71697

    barryo
    Participant

    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

    It goes into your child theme functions.php file.


    Changes in Genesis 2.1 – the ultimate guide to every single change in Genesis Framework 2.1, 2.1.1 and 2.1.2 (all 90 of them!) | @GaryJ

    #71704

    barryo
    Participant

    Awesome. Thanks.

    #71711

    barryo
    Participant

    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

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


    Changes in Genesis 2.1 – the ultimate guide to every single change in Genesis Framework 2.1, 2.1.1 and 2.1.2 (all 90 of them!) | @GaryJ

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

You must be logged in to reply to this topic.