• Resolved slade470

    (@slade470)


    i need help,
    Depending on whether a post has been edited or is created for the first time, I would like to take a different action.

    My goal is to display the date of the post was created ( $published_date ) , if it was only published for the first time and was never updated or edited.

    and to display the updated date if a post was updated/edited ($update_date).

    but it seems my code isn’t working, Here is my code.

    $published_date =  get_the_date( 'F j, Y' );
    $update_date = get_the_modified_time( 'F j, Y' );
    if( get_the_modified_time() == get_the_time()){
    echo $published_date;
    }
    else{
    echo $update_date;
    }
    }

    Thank you.

    • This topic was modified 2 years, 2 months ago by Jan Dembowski.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Even though your code is not optimal, it worked when I tested it in a post template file.

    Can you explain exactly what you did and what’s not working?

    • This reply was modified 2 years, 2 months ago by George Appiah.
    Thread Starter slade470

    (@slade470)

    I appreciate you taking the time to look at my code.
    Yes, I have figured out the error and it has been resolved.
    Once again, thank you.

    Thread Starter slade470

    (@slade470)

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘If condition to display post published date and update date’ is closed to new replies.