I have a shortcode that I have been using for awhile that is suddenly causing a warning in WordPress 6.5 the error is "Warning: Array to string conversion in ... on line 109" - line 109 is below at $content .= ob_get_clean();
What I am finding on researching this warning is that I need to implode or join the array but I am not sure how that applies to this. Any ideas?
function my_annoucement_shortcode($content) {
global $post;
$args = array(
'post_type' => array( 'announcement' ),
'nopaging' => true,
'posts_per_page' => '1',
);
$ann_query = new WP_Query( $args );
if ( $ann_query->have_posts() ) {
ob_start();
while ( $ann_query->have_posts() ) { $ann_query->the_post();
echo '<div class="announcement-content">';
the_content();
echo '</div>';
}
wp_reset_query();
$content .= ob_get_clean();
return $content;
}
}
add_shortcode( 'announcements', 'my_annoucement_shortcode' );