WordPress.org

Ready to get started?Download WordPress

Forums

Change Post Time to Get Text if left Blank (3 posts)

  1. RTDE
    Member
    Posted 1 year ago #

    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. :)

    Regards

    E

  2. Aaron
    Member
    Posted 1 year ago #

    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.

  3. RTDE
    Member
    Posted 1 year ago #

    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 :)

Topic Closed

This topic has been closed to new replies.

About this Topic