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/infografiche.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[] = "Il Consorzio";
$infografiche[] = "Risultati e Benefici";
$infografiche[] = "Ciclo di vita degli imballaggi";
$infografiche[] = "Cosa si fa con la plastica riciclata";
$infografiche[] = "Sostenibilita";


$entity_id = array();
$infografica = array();
$rows =  $wpdb->get_results( "select entity_id, field_tipo_infografica_id_value from field_data_field_tipo_infografica_id;" , ARRAY_A);
foreach($rows as $row){
	$entity_id[] = $row['entity_id'];
	$infografica[] = $row['field_tipo_infografica_id_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'       => 'infografiche',
                                    'selezione_infografica' => $infografiche[$infografica[$i]]
                                ], $post_id);

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

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