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/corepla/mappe.php
<?php 
require_once( '/var/www/html/corepla/wp-load.php' ); 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$infografiche = array();
$infografiche[] = "";
$infografiche[] = "CSS";
$infografiche[] = "CDR";
$infografiche[] = "Riciclo Imprese (PEPS; PIA; PIFU)";
$infografiche[] = "ECP";
$infografiche[] = "Clienti";
$infografiche[] = "Comuni convenzionati";
$infografiche[] = "CC";
$infografiche[] = "CSS con distinzione visita";
$infografiche[] = "RIC";

$entity_id = array();
$infografica = array();
$rows =  $wpdb->get_results( "select entity_id, field_tipo_mappa_value from field_revision_field_tipo_mappa;" , ARRAY_A);
foreach($rows as $row){
	$entity_id[] = $row['entity_id'];
	$infografica[] = $row['field_tipo_mappa_value'];
}
$i = 0;
while ($i < count($entity_id)) {
	$post_id = -1;
	$rows =  $wpdb->get_results( "select post_id from wp_postmeta where meta_value = " . $entity_id[$i] . " and meta_key = '_fgd2wp_old_node_id ';" , ARRAY_A);
	foreach($rows as $row){
		$post_id = $row['post_id'];
        if ($post_id > -1) {
                                add_row(
                                    'contenuto_flessibile', [
                                    'acf_fc_layout'       => 'mappa',
                                    'mappa_id' => $infografiche[$infografica[$i]]
                                ], $post_id);


echo $post_id . " " . $infografiche[$infografica[$i]] . "\n";
        }

	}
	$i++;
}
echo "done";
?>