HEX
Server: Apache
System: Linux webd003.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: slyfwmm (169339)
PHP: 8.1.34
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/slyfwmm/incastiglionfiorentino/wp-content/themes/amplify/cerca_strutture.php
<?php
/**
 * Template Name: Cerca Strutture
 *
 * Template per mostrare i risultati di ricerca delle strutture selezionate dal modulo di ricerca laterale
 */

get_header(); ?>

<div id="main_container">

<!-- IE7 float fix --><!--[if lt IE 7]><span class="iefix">.</span><![endif]-->

	<div class="main">
	
			<div class="entries_full">
			
				<div class="entry_full">
				
				<div class="box_twothirds mt35 pr60">

					<?php
					
					
				
						$inserzioni = array();
						
						foreach ($_POST['tipi-seleziona'] as $n)
						{
							$inserzioni [] = $n;
						}

						
						$locazioni = array();
						
						foreach ($_POST['locazioni-seleziona'] as $n)
						{
							$locazioni [] = $n;
						}
						
						$servizi = array();
						
						foreach ($_POST['servizi-seleziona'] as $n)
						{
							$servizi [] = $n;
						}
						

						
						$meta_q = array ('relation' => 'AND');
							
						$lista_inserzioni = "";		
						$lista_locazioni = "";		
						$lista_servizi = "";
						$cerca = "";
								
						if (count($inserzioni) != 0) { 
					
							$meta_q [] = array(
								'taxonomy' => 'inserzione',
								'field' => 'slug',
								'terms' => $inserzioni
							);
									
							foreach ($inserzioni as $inserzione)
							{											
								if($lista_inserzioni == "")
								{
									$lista_inserzioni = $inserzione;
								} else
								{
									$lista_inserzioni = $lista_inserzioni . ", " . $inserzione;
								} 
							}
							
							$cerca = $cerca . $lista_inserzioni;
						}
						
						if (count($locazioni) != 0) { 
		
							$meta_q [] = array(
								'taxonomy' => 'locazione',
								'field' => 'slug',
								'terms' => $locazioni
							);
							
							foreach ($locazioni as $locazione)
							{									
									if($lista_locazioni == "")
									{
										$lista_locazioni = $locazione;
									} else
									{
										$lista_locazioni = $lista_locazioni . ", " . $locazione;
									}
							}
							
							if($cerca == "")
							{
								$cerca = $cerca . $lista_locazioni; 
							}else
							{
								$cerca = $cerca . " - " . $lista_locazioni; 
							}
					
						}
						
						if (count($servizi) != 0) { 
					
							
							$meta_q [] = array(
								'taxonomy' => 'servizi',
								'field' => 'slug',
								'terms' => $servizi
							);									
							
							foreach ($servizi as $servizio)
							{	
									if($lista_servizi == "")
									{
										$lista_servizi = $servizio;
									} else
									{
										$lista_servizi = $lista_servizi . ", " . $servizio;
									}
							}
							
							if($cerca == "")
							{
								$cerca = $cerca . $lista_servizi; 
							}else
							{
								$cerca = $cerca . " - " . $lista_servizi; 
							}
						
						}
					
						if($cerca != "")
						{
							$args = array(
								'tax_query' => $meta_q,
								'orderby' => 'rand'
							);						
						}else
						{
							$inserzione = 'inserzione';
                            $elenco_inserzioni = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT $wpdb->terms.name FROM $wpdb->term_taxonomy, $wpdb->terms WHERE taxonomy = %s AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id ORDER BY $wpdb->terms.name ASC", $inserzione) );

							$args = array(
								'tax_query' => array(
									'relation' => 'OR',
									array(
										'taxonomy' => 'inserzione',
										'field' => 'slug',
										'terms' => $elenco_inserzioni
									)	
								),'orderby' => 'rand'
								
							);
						}
						
						
						
						query_posts($args);
		
	
						?>
						<h4><?php echo $ser; if ($cerca == "") { echo $ser2; } else { echo $cerca; } ?></h4><br /><br />
					
						
						<?php $count = 0; ?>
						<?php if (have_posts()) :  while (have_posts()) : the_post(); ?>
					
                            <!-- displays the blog posts -->
                            <?php $count++; if($count > 3) { $count = 1; } ?>
                             
                                            
                            <h3 class="<?php if($count > 1) echo "mt25 "; ?>mb12"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    
<div id="tassonomie-sotto-titolo"><div id="icona-tassonomia"><img src="<?php echo get_template_directory_uri(); ?>/images/tipo.jpg" /></div><div class="meta" style="margin-bottom: 20px; float: left;"><?php _e(get_the_term_list( get_the_ID(), 'inserzione', "" )) ?></div><div id="icona-tassonomia" style="margin-left: 20px;"><img src="<?php echo get_template_directory_uri(); ?>/images/location.jpg" /></div><div class="meta"><?php _e(get_the_term_list( get_the_ID(), 'locazione', "" )) ?></div></div>
                            
                            <?php if(get_field('large_image_value') != NULL || get_field('fullsize_value') != NULL)
                            { ?>
                            <div class="mag_blog"><!-- magnifying glass div -->
                            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/scripts/timthumb.php?src=<?php if(get_field('large_image_value') != NULL) {echo get_field('large_image_value');} else {echo get_field('fullsize_value');} ?>&amp;h=213&amp;w=600&amp;zc=1" alt="<?php the_title(); ?>" /></a>
                            </div><!-- end magnifying glass div -->
                            <?php } ?>
                            
                            <div id="icona-tassonomia"><img src="<?php echo get_template_directory_uri(); ?>/images/services.jpg" /></div><div class="meta" style="margin-bottom: 20px;"><?php _e(str_replace("</a><!--:-->", "<!--:--></a>", str_replace("[:it]", "<!--:it-->", str_replace("[:en]", "<!--:--><!--:en-->", get_the_term_list( get_the_ID(), 'servizi', "","<!--:-->, ","<!--:-->" )))));?></div>
                            
                            <div id="info-box-elenco">
                                                            
                                <?php
                                
                                $struttura_id=get_the_ID();
                                  
                                  echo "<div id=\"indirizzo-sitoweb-struttura-elenco\">";
                                
                                
                                  $metakey = 'indirizzo';
                                  $t = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s ORDER BY meta_value ASC", $struttura_id, $metakey) );
                                  if ($t) {
                                    foreach ($t as $s) {
										if (($s != "") && ($s != " ") && ($s != NULL))
										{
                                      		echo "<div style=\"float: left; margin-right: 6px; margin-top: -3px;\"><img src=\"" . get_template_directory_uri() ."/images/address.jpg\" /></div><div class=\"meta\" style=\"margin-bottom: 20px;\">" . $s . "</div>";
										}
									}
                                  }
                               
                             
                                  $metakey = 'sito_web';
                                  $t = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s ORDER BY meta_value ASC", $struttura_id, $metakey) );
                                  if ($t) {
                                    foreach ($t as $s) {
										if (($s != "") && ($s != " ") && ($s != NULL))
										{
                                      		echo "<div style=\"float: left; margin-right: 6px; margin-top: -3px;\"><img src=\"" . get_template_directory_uri() ."/images/web.jpg\" /></div><div class=\"meta\" style=\"margin-bottom: 20px;\"><a href=\"" . $s . "\" target=\"blank\" rel=\"nofollow\">" .$s. "</a></div>";
										}
                                    }
                                  }
                                  
                                  echo "</div>";
                                  
                                  echo "<div id=\"telefono-struttura-elenco\">";
                                  
                                  $metakey = 'telefono';
                                  $t = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s ORDER BY meta_value ASC", $struttura_id, $metakey) );
                                  if ($t) {
                                    foreach ($t as $s) {
										if (($s != "") && ($s != " ") && ($s != NULL))
										{
		                                      echo "<div style=\"float: left; margin-right: 6px; margin-top: -3px;\"><img src=\"" . get_template_directory_uri() ."/images/phone.jpg\" /></div><div class=\"meta\" style=\"margin-bottom: 20px;\">" . $s . "</div>";
										}
                                    }
                                  }
                              
                                  $metakey = 'telefono_secondario';
                                  $t = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s ORDER BY meta_value ASC", $struttura_id, $metakey) );
                                  if ($t) {
                                    foreach ($t as $s) {
                                      if (($s != "") && ($s != " ") && ($s != NULL))
                                      {
                                        echo "<div style=\"float: left; margin-right: 6px; margin-top: -3px;\"><img src=\"" . get_template_directory_uri() ."/images/phone.jpg\" /></div><div class=\"meta\" style=\"margin-bottom: 20px;\">"  . $s . "</div>" ;
                                      }
                                    }
                                  }
                          
                                echo "</div>";
                            
                                ?>
                            </div>
                            <div id="contenuto">                
                            <?php global $more; $more = false; ?><?php the_content($info); ?><?php $more = true; ?>
                            </div>                
                            <div class="bar mt25 mb30"></div>
                            
                             <!-- ARCHIVE POSTS END -->
                             <?php endwhile;
                              if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
                              else { ?>
                            <?php /* Display navigation to next/previous pages when applicable */ ?>
                            <?php if (  $wp_query->max_num_pages > 1 ) : ?>
                                            <?php next_posts_link( __( '&larr; Older posts', 'amplify' ) ); ?>&nbsp;
                                            <?php previous_posts_link( __( 'Newer posts &rarr;', 'amplify' ) ); ?>
                            <?php endif; ?>
                            
                            <?php } ?>							
				
						
						<?php else :
						
							_e("[:it]Siamo spiacenti, nessun risultato per i parametri selezionati.[:en]Sorry, no results for your search.");
						
						 endif; ?>
					
						<?php wp_reset_query(); ?>


				</div>

<!-- Begin Sidebar -->
<?php 
if(get_field('custom_sidebar_value') != NULL) 
	{include get_field('custom_sidebar_value');}
	else {include('sidebar.php');} ?>
<!-- end sidebar -->
							
				<div class="clear"></div>

				</div><!-- end div.entry -->
				
			</div><!-- end div.entries -->

	<div class="clear"></div>
		
	</div><!-- end div#main -->
	
	<div class="clear"></div>
	
</div><!-- end div#main_container-->

<?php get_footer(); ?>