Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #650089

    I added php date shortcode to the function.php page, so I could have a date in the header of my site. The problem is the date is incorrect.

    Here is what I did:
    1.) I added the following code in the bottom of function.php file:
    add_action( ‘ava_inside_main_menu’, ‘enfold_customization_add_date’ );
    function enfold_customization_add_date() {
    echo ‘<span class = “header_date”>’.get_the_time(‘F j, Y’).'</span>’;
    }

    2.) In the Quick CSS, I added:
    .header_date {
    position: absolute;
    left: 86%;
    }

    A date appears right where I want it, but the date is wrong.

    Suggestions on how to fix this? I have included my login credentials in the Private Content area.

    Thanks,
    Kurt

    #650214

    Hey Kurt,

    Thanks for getting in touch with us!

    I think the correct function you are looking to use is the current_time()https://codex.wordpress.org/Function_Reference/current_time

    The get_the_time function displays the time or date a post or page was published.

    Let me know if you need further assistance.

    Best regards,
    Jordan

    #650256

    Jordan:

    I checked out the codex and got very confused, because I don’t want the time or results returned in numerals. I am seeking something like, June 18, 2016.

    Below is the code I put at the bottom of the function.php file. Unfortunately, it returns the date of June 6, 2016, which is wrong.

    Here is the code in the bottom of the function.php file. Could you suggest another change in the last line to make it work?
    add_action( ‘ava_inside_main_menu’, ‘enfold_customization_add_date’ );
    function enfold_customization_add_date() {
    echo ‘<span class = “header_date”>’.get_the_time (‘F j, Y’).'</span>’;
    }

    Thanks,

    #650261

    Hi,

    Thanks for getting back to me!

    I made the correct change to the code for you. Here is what it looks like now:

    add_action( 'ava_inside_main_menu', 'enfold_customization_add_date' );
    function enfold_customization_add_date() {
    echo '<span class = "header_date">'.date_i18n ('F j, Y').'</span>';
    }

    That still displays the date in words rather than numbers and it is the current date.

    Let me know if you need further assistance.

    Best regards,
    Jordan

    #650268

    Jordan:

    Absolutely perfect! Thank you.

    I see you check the last line, changing .get_the_time to .date_i18n.

    Terrific. Thank you so much.
    Kurt

    #650614

    Hi Kurt,

    Great, glad we could help :-)

    Best regards,
    Rikard

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.