Display year in post date

  • Anonymous


    Excellent theme. Easy to manipulate. Thanks. Although I am trying to figure out how to have the year of a post displayed in the date.


    Anything you can do to help would be great.


    Syahir Hakim


    Using a child theme, you can use the graphene_post_date action hook to hook your own function to display the date, and then hide the default date using CSS.



    Hi Syahir ~ just created a child theme and want to add the year into the date, too. Don’t quite understand how to do what you said to do, though. Could you provide a bit more detail please?



    can you provide a bit more detail about how to do this, please? thanks.


    Syahir Hakim


    I think the easier way to this is this way:

    1. Go to Graphene Display options page, and check Hide post date.

    2. Using a child theme’s functions.php file, create a function that will display the full post date including the year.

    3. Hook the above function to the graphene_post_meta action hook.

    4. Position the date using CSS.

    The function to create in the functions.php and the hook should look something like this:

    function graphene_custom_post_date(){ ?>
    <div class="custom_date"><?php the_time(get_option('date_format')); ?></div>
    add_action('graphene_post_meta', 'graphene_custom_post_date');

    Don’t forget to position and style the custom date using CSS.



    Simplier way :

    In loop.php find

    <p class="default_date"><?php the_time('M'); ?><br /><span><?php the_time('d') ?></span></p>

    And replace “M” by “Y” and “d” by “m”.

    So, graphene will displays “year + month” instead of “Month + day”.

    Thanks for the great theme.


    Syahir Hakim



    The method you outlined is of course, easier, but is not recommended. This is because it involves editing the theme’s core files directly, which will cause you to lose the modification the next time you update the theme.



    Thanks for this advise

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

  • You must be logged in to reply to this topic.