Recoverable Fatal Error – Object of class WP_Post could not be converted to string

Question

Im using ACF and trying to show a post type title based on the current time. So I have my post type entry with start_time and end_time and my conditional is showing my div.onAir, but Im getting this Recoverable Fatal Error. Here is my code:

<?php
    $time_now = date("g:i a");
    $shows = get_posts( array(
      'post_type' => 'shows',
      'meta_query' => array(
        array(
          'key' => 'start_time',
          'compare' => '<=',
          'value' => $time_now,
          'type' => 'DATETIME',
        ),
        array(
          'key' => 'end_time',
          'compare' => '<=',
          'value' => $time_now,
          'type' => 'DATETIME',
        )
      ),
    ));
  if( $shows ) {
    foreach( $shows as $show ){ ?>
       <div class="onAir">
         Currently On Air: <?php echo the_title($show); ?>
       </div>
  <?php
  wp_reset_query();
}
} ?>

I feel Im close, but I haven’t seen this particular error before. Any help would be appreciated! Thanks.

0
, , , TractionW 3 years 2020-04-03T16:53:19-05:00 0 Answers 104 views 0

Leave an answer

Browse
Browse