Support » Fixing WordPress » Just Need A quick way to add and if – else statement to this

  • What I want this to do is to show update only if the post is updated, done with the code, but I can seem to get around with the if-else statement

    Original Code

    function givi_posted_on() {
    		$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    		if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    			$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';

    Function to update the code

    		$u_time = get_the_time('U'); 
                    $u_modified_time = get_the_modified_time('U'); 
                    if ($u_modified_time >= $u_time + 86400) { 
                    echo '<p class = "last-updated-up">Last updated on '; 
                    the_modified_time('F jS, Y'); 
                    echo "</p> "; } 
    		} 

    How do I go around with the if-else statement, thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • What’s your ELSE if the IF doesn’t exist?

    Thread Starter Horlayemi

    (@horlaes)

    That’s the main problem I have with the code, it is basically structured this way:

    if ( ! function_exists( 'givi_posted_on' ) ) :
    	/**
    	 * Prints HTML with meta information for the current post-date/time.
    	 */
    	function givi_posted_on() {
    		$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    		if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    			$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
    			
    		
    		
    		
    			
    		    /**
                * Function to show last updated date
                */
    		
    		$u_time = get_the_time('U'); 
                    $u_modified_time = get_the_modified_time('U'); 
                    if ($u_modified_time >= $u_time + 86400) { 
                    echo '<p class = "last-updated-up">Last updated on '; 
                    the_modified_time('F jS, Y'); 
                    echo "</p> "; } 
    		} 

    Lead me thru please….

    • This reply was modified 3 years, 10 months ago by Horlayemi.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Just Need A quick way to add and if – else statement to this’ is closed to new replies.