function cloud_carica_lista_profili()
{
    global $wpdb;
    $tipo_profilo = $_REQUEST['tipo_profilo'];
    $where = $_REQUEST['where'];
    $where = stripcslashes($where);
    $where = json_decode($where);
    if (!empty($where->specializzazioni)) {
        $where_spec = '';
        $specs = explode("#", $where->specializzazioni);
        foreach ($specs as $spec) {
            if (!empty($spec)) {
                $where_spec .= ' specializzazioni like "%' . $spec . '%" OR ';
            }
        }
        //foreach
        $where_spec = substr($where_spec, 0, -3);
        //tolgo l'ultimo AND
    }
    //specializzazioni
    if (!empty($where->provincia)) {
        $where_prov = ' provincia like "%' . $where->provincia . '%" ';
    }
    //provincia
    if (!empty($where->sesso)) {
        $where_sesso = ' sesso like "%' . $where->sesso . '%" ';
    }
    //sesso
    $sql = '';
    $sql .= ' 	SELECT * from fjob_wp_users		';
    $sql .= ' 	INNER JOIN fjob_wp_cld_utenti on fjob_wp_cld_utenti.user_id = fjob_wp_users.id		';
    $sql .= ' 	WHERE tipo_profilo = "' . $tipo_profilo . '" ';
    if (!empty($where->specializzazioni)) {
        $sql .= ' AND (' . $where_spec . ') ';
    }
    if (!empty($where->provincia)) {
        $sql .= ' AND (' . $where_prov . ') ';
    }
    if (!empty($where->sesso)) {
        $sql .= ' AND (' . $where_sesso . ') ';
    }
    $sql .= ' 	ORDER BY nome	';
    //$sql .= ' 	stato = 1	';
    $rows = $wpdb->get_results($sql);
    if (count($rows) > 0) {
        ob_start();
        ?>

							<?php 
        foreach ($rows as $row) {
            if ($tipo_profilo == 'azienda') {
                $link_url = get_permalink(903) . $row->user_id;
                //dettaglio-azienda
            } else {
                $link_url = get_permalink(867) . $row->user_id;
                //pag-profilo
            }
            //tipo_profilo
            ?>


											<div class="element isotope-item">
											<a href="<?php 
            echo $link_url;
            ?>
"><img class='img-responsive' alt="//" src="<?php 
            echo carica_foto_profilo($row->user_id);
            ?>
"></a>
											<?php 
            if ($tipo_profilo == 'azienda') {
                ?>

												<div class='element_info'><a href="<?php 
                echo $link_url;
                ?>
"><?php 
                echo $row->ragione_sociale;
                ?>
</a></div><!-- /.element_info -->
											<?php 
            } else {
                ?>

													<a href="<?php 
                echo $link_url;
                ?>
">
													<div class="background">
													<div class="text">
													<div class="info">
															<p><i class="icon-user">&nbsp;</i><?php 
                echo $row->nome;
                ?>
 <?php 
                echo $row->cognome;
                ?>
</p>
															<span><i class="icon-doc-text"></i></span>
													</div>
													</div><!-- /text -->
													</div><!-- /background -->
													</a>
											<?php 
            }
            ?>

											</div><!-- /element -->
											<?php 
        }
        //foreach
        ?>

			<?php 
    } else {
        ?>

							<div class="loading-ajax">Nessun risultato per la ricerca eseguta...</div>
			<?php 
    }
    //count
    ?>


	<div style="clear:both"></div><!-- / -->

	<!-- DEBUG -->
	<pre><?php 
    echo $sql;
    ?>
</pre>

	<?php 
    $output = ob_get_clean();
    echo $output;
    exit;
}
<div class="row pag_profilo">



        <!-- --------- GALLERY ------------ -->
        <div class="col-md-4">
        <div id="img-trainer" class="carousel slide">
				<div class="carousel-inner">
						<?php 
$alt = $prof->nome . " " . $prof->cognome;
$upload_dir = wp_upload_dir();
$upload_dir = $upload_dir['baseurl'] . '/profiles/' . $prof->ID . '/';
/*- foto -*/
echo '<div class="item active">';
echo '<img xxclass="img-responsive" src="' . carica_foto_profilo($prof->ID) . '" alt="' . $alt . '">';
echo '</div>';
/*- gallery -*/
$gallery = explode(";", $prof->gallery);
foreach ($gallery as $gal) {
    if ($gal != '') {
        echo '<div class="item">';
        echo '<img xxclass="img-responsive" src="' . $upload_dir . $gal . '" alt="' . $alt . '">';
        echo '</div>';
    }
    //gal
}
//foreach
?>

						</div>