php - Wordpress custom search results -


i have wordpress custom search form used search floors various buildings. example, when user searches floor between 1000 , 1500 sq ft, list of buildings free floor spaces between values.

the search values stored inside cookies need them on single building page.

on single building page there section showing floors match user's search criteria.

it works fine floors have added time ago. when add new floors don't show on single building page

what be? here code i've written show matching floors single building page:

<table class="table" id="tab1c">     <?php include( get_template_directory().'/inc/function-search.php' );     $categories = get_the_category();     $category_id = $categories[0]->cat_name;     $args = array(         'meta_query'    =>  array(                                 $sq_array,                                 $mt_array,                                 $prelet_array,                                 $date_array,                             ),         'category_name' => $category_id,     );      $i = 0;     $search = array_merge($args);      $propertysearch = new wp_query( $search ); ?>     <?php $terms = get_the_terms( get_the_id(), 'category');     if( !empty($terms) ) : $term = array_pop($terms); ?>         <?php if( $propertysearch->have_posts() ) : while( $propertysearch->have_posts() ) : $propertysearch->the_post(); ?>             <?php get_template_part( 'content', 'table' ); ?>             <?php $i++; ?>         <?php endwhile; endif;           wp_reset_postdata(); ?>     <?php endif; ?> </table> 

this function-search.php include

<?php  $_minsq     = $_get['minsq'] != '' ? $_get['minsq'] : ''; $_maxsq     = $_get['maxsq'] != '' ? $_get['maxsq'] : ''; $_minmt     = $_get['minmt'] != '' ? $_get['minmt'] : ''; $_maxmt     = $_get['maxmt'] != '' ? $_get['maxmt'] : ''; $unit   = $_get['unit'] != '' ? $_get['unit'] : ''; $prelet     = $_get['prelet'] != '' ? $_get['prelet'] : ''; $date   = $_get['date'] != '' ? $_get['date'] : '';  $sorter     = $_get['sorter'] != '' ? $_get['sorter'] : '';  $sq_array       = array(); $mt_array       = array(); $prelet_array   = array(); $date_array     = array(); $sorter_array   = array();   if ( isset( $_cookie["unit"] )){     if ($_cookie["unit"] == "ft") {         if ( isset( $_cookie["minsq"] )){             $value_min = intval( $_cookie["minsq"] );             //update_post_meta( $post->id, 'wpcf-square-feet', $value_min );           }         if ( isset( $_cookie["maxsq"] )){             $value_max = intval( $_cookie["maxsq"] );             //update_post_meta( $post->id, 'wpcf-square-feet', $value_max );           }          $sq_array = array(             array (                 'key'     => 'wpcf-square-feet',                 'value'   => array( $value_min, $value_max ),                 'type'    => 'numeric',                 'compare' => 'between',             ),             array(                 'key'     => 'wpcf-square-feet',                 'value'   => $value_min,                 'type'    => 'numeric',                 'compare' => '>=',             ),             array(                 'key'     => 'wpcf-square-feet',                 'value'   => $value_max,                 'type'    => 'numeric',                 'compare' => '<=',             )         );     } elseif ($_cookie["unit"] == "mt") {         if ( isset( $_cookie["minmt"] )){             $value_minmt = intval( $_cookie["minmt"] );             //update_post_meta( $post->id, 'wpcf-square-meters', $value_minmt );           }         if ( isset( $_cookie["maxmt"] )){             $value_maxmt = intval( $_cookie["maxmt"] );             //update_post_meta( $post->id, 'wpcf-square-meters', $value_maxmt );           }          $mt_array = array(             array (                 'key'     => 'wpcf-square-meters',                 'value'   => array( $value_minmt, $value_maxmt ),                 'type'    => 'numeric',                 'compare' => 'between',             ),             array(                 'key'     => 'wpcf-square-meters',                 'value'   => $value_minmt,                 'type'    => 'numeric',                 'compare' => '>=',             ),             array(                 'key'     => 'wpcf-square-meters',                 'value'   => $value_maxmt,                 'type'    => 'numeric',                 'compare' => '<=',             )         );     } }  if ( isset( $_cookie["prelet"] )){     if ($_cookie["prelet"] != "yes") {         $value_prelet = 2;         //update_post_meta( $post->id, 'wpcf-prelet', $value_prelet );          $prelet_array = array(             'key'     => 'wpcf-prelet',             'value'   => $value_prelet,             'type'    => 'numeric',             'compare' => '=',         );     }    };   if ( isset( $_cookie["date"] ) &&   $date != ""){     $value_date = intval( $_cookie["date"] );     //update_post_meta( $post->id, 'wpcf-completition-date', $value_date );       $date_array = array(         'key'     => 'wpcf-completition-date',         'value'   => $value_date,         'type'    => 'numeric',         'compare' => '=',     ); };  if ( isset( $sorter )){     if ($sorter == "0") {         $sorter_array = array(             'meta_key'  => 'wpcf-square-feet',             'orderby'   => 'meta_value_num',             'order'         => 'desc'         );     } elseif ($sorter == "1") {         $sorter_array = array(             'meta_key'  => 'wpcf-square-feet',             'orderby'   => 'meta_value_num',             'order'         => 'asc'         );     } }  ?> 

this single building page floor shows up

enter image description here

and single building page floor don't show up

enter image description here

they both use same code , have same search criteria doesn't work newly added floors.

i hope makes sense , there soul able me out. have deliver tomorrow morning @ 9am uk time , i've been trying fix day no success. appreciate help, thank you.

the issue category name, started number..! changed string , works. 5 hours later....


Comments