Support » Fixing WordPress » Change Post Time to Get Text if left Blank

  • Hi All,

    just wondering, I run a football website where certain matches do not have a confirmed time of kick off, I was wondering if there is a possible way to replace post time with text, ie: TBC or To Be Confirmed if no time is entered in the post time and date section, just has to be the time as the date is mostly confirmed, however an overall Text overwrite if no post date and time entered would be equally as awesome. 🙂

    many thanks in advance. 🙂



Viewing 2 replies - 1 through 2 (of 2 total)
  • This post time/date has a lot more functionality then just displaying the time/date so I would recommend leaving that part alone.

    What I would do is just create a separate heading or text within the post where you can just put your text “TBC” in it.

    there must be something I can do in order to replace strtotime
    with an if else function, say if I set the start time to 00:00 then this will output as TBC

    below is an excerpt of the script being used.

    $timestamp = strtotime( $match->post_date  );
    				$gmt_offset = get_option( 'gmt_offset' );
    				$date_format = get_option( 'date_format' );
    				$time_format = get_option( 'time_format' );
    				$output .=
    				'<li class="'.( $count % 2 == 0 ? 'even' : 'odd').' '.( $count == $size ? ' last' : '').'">
    					<div class="kickoff">
    						<div class="home-logo">' . get_the_post_thumbnail( $home_club, 'crest-medium', array( 'title' => get_the_title( $home_club ) ) ) . '</div>
    						<div class="away-logo">' . get_the_post_thumbnail( $away_club, 'crest-medium', array( 'title' => get_the_title( $away_club ) ) ) . '</div>
    						<a>ID ) . '">' . date( $date_format, $timestamp ) . '</a>
    						<time>' . date( $time_format, $timestamp ) . '</time>

    hope someone can help, 20 euro paypal transfer if they can help me out 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change Post Time to Get Text if left Blank’ is closed to new replies.