foreach return displays double results

Seems I have a little bug in my WP code. When I add the shortcode to my page, it displays the results twice.

If I use echo this will post at the top of the page, I want to enable to shortcode so it can be placed where ever.

Can anyone see what I am missing?

function today_quote(){
global $wpdb;
$table_name = $wpdb->prefix . “daily_verse”;
$daily_verse = $wpdb->get_results( “SELECT * FROM $table_name” );

$numbers = ”;

foreach ($daily_verse as $data){
$numbers .= $data->verse . “<br><br>”;
}
return $numbers . ‘<br>’;
}
add_shortcode(‘365_verse’, ‘today_quote’);
?>

Read more here:: foreach return displays double results

Leave a Reply

Your email address will not be published. Required fields are marked *