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 11 months, 1 week ago.

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

    barryo
    Participant
    Post count: 7

    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: 693

    Try:

    [php]
    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 ) . ‘‘,
    $menu
    );
    }
    [/php]


    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
    Post count: 7

    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: 693

    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
    Post count: 7

    Awesome. Thanks.

    #71711

    barryo
    Participant
    Post count: 7

    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: 693

    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.