HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.34
System: Linux atalantini.com 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38 UTC 2020 x86_64
User: root (0)
PHP: 7.2.34
Disabled: NONE
Upload Files
File: /var/www/html/www.uscornatese.it/json/topnews.php
<?php
require_once('../wp-load.php' );
global $wpdb;

$maxLastNews =  100;
$sql = "(select * from wp_posts where post_status = 'publish' and id in (select object_id from wp_term_relationships where term_taxonomy_id = 5)) order by post_date desc limit 0, " . $maxLastNews. ";";
$records = $wpdb->get_results($sql);

$values = array();
foreach ( $records as $record )  {
	$id = $record->ID;
        $content = $record->post_content;
        $content = preg_replace( '/(width|height)="\d*"\s/', "", $content );
        $content = str_replace("<img ", "<img width=\"300\"  ", $content);
        $record->post_content = $content;
	$date = $record->post_date;
	$pdate = explode("-", substr($date, 0, 10));
	$post_date = $pdate[2] . "-" . $pdate[1] . "-" . $pdate[0]; 
        $record->post_title = strip_tags(strtolower($record->post_title));
	$record->post_date = $post_date . " " . substr($date, 11, 8);
        $image = get_the_post_thumbnail_url($id);
//	echo $record->post_title . " " . $path . " " . $image . "<br>";
        $record->image = $image;
        //if ($image != "") {
        //       $record->image = Img_Resize($image, "570", "thumb");
        //}
	$values[] = $record;
}
echo json_encode($values);
?>