PHP WPDB Foreach
get_header();
function get_records()
{
//$con=connectsql();
$records=$wpdb->query("SELECT * FROM $wpdb->posts WHERE post_type = 'elements' AND post_status = 'publish'");
$all=array();
while($data=$records->fetch_assoc())
{
$all[]=$data;
}
return $all;
}
Matteoweb