$s); $defaultSearchTitle = "Search Results for:"; $busca = get_query_var('s'); $buscar = "+".str_replace(" "," +",$busca); //$buscar = $busca; //OBTER LISTA DE PRODUTOS 3D //$sql = $wpdb->prepare("SELECT * FROM 3dcrystal_product_categories LEFT JOIN 3dcrystal_products ON 3dcrystal_products.id = 3dcrystal_product_categories.productid WHERE 3dcrystal_products.name LIKE %s LIMIT 99",Array($buscar)); //SELECT * FROM 3dcrystal_product_categories LEFT JOIN 3dcrystal_products ON 3dcrystal_products.id = 3dcrystal_product_categories.productid WHERE MATCH (reference,name,shortdesc,fulldesc) AGAINST (%s IN NATURAL LANGUAGE MODE) LIMIT 99 // IN BOOLEAN MODE $sql = $wpdb->prepare("SELECT * FROM 3dcrystal_product_categories LEFT JOIN 3dcrystal_categories ON (3dcrystal_categories.id = 3dcrystal_product_categories.categoryid) LEFT JOIN 3dcrystal_products ON 3dcrystal_products.id = 3dcrystal_product_categories.productid WHERE MATCH (reference,name,shortdesc,fulldesc) AGAINST (%s IN BOOLEAN MODE) AND active = 1 LIMIT 99",Array($buscar)); //echo $sql; $r = $wpdb->get_results($sql, ARRAY_A); $productlist = ""; $i = 1; $c = 0; $inlist = Array(); foreach($r as $product){ $pid = $product['id']; if($inlist[$pid] != 1){ $inlist[$pid] = 1; $cls = "one_third"; $image = "No Image Available"; //get product image unset($r1); $sql = $wpdb->prepare("SELECT id,file,description,image_title,image_alt,background FROM 3dcrystal_images WHERE productid = %d ORDER BY ordem ASC LIMIT 1",Array($product['id'])); $r1 = $wpdb->get_results($sql, ARRAY_A); $bg = ""; if($r1[0]['file'] != ""){ $img_title = $r1[0]['description']; $img_alt = $r1[0]['description']; if($r1[0]['image_title'] != ""){$img_title = $r1[0]['image_title'];} if($r1[0]['image_alt'] != ""){$img_alt = $r1[0]['image_alt'];} $url = "/wp-content/plugins/3dcrystal/xcrud/uploads/".$r1[0]['file']; $image = "$img_alt"; if($r1[0]['background'] != ""){ $r1[0]['background'] = str_replace("#","",$r1[0]['background']); $bg = "style='background:#".$r1[0]['background']."!important'"; } } if($i==3){$cls = "one_third et_column_last";} $slug = $product['slug']; $productslug = sanitize_title($product['name']); $productlist .= "";//

$product[name]

"; if($i==3){ $productlist .= "
"; $i=0; } $i++; $c++; } } if($cls != "one_third et_column_last"){ $productlist .= "
"; } $productlist .= "
"; // OBTER LISTA DE RESULTADOS DEFAULT WP $the_query = new WP_Query( $args ); $resultadosDefault = ""; $defaultCount = 0; if ( $the_query->have_posts() ) { //$buscar = $busca; while ($the_query->have_posts() ) { $the_query->the_post(); $link = get_permalink(); $title = get_the_title(); $excerpt = get_the_excerpt(); $resultadosDefault .= "

$title

$excerpt
"; $defaultCount++; } } $weHaveResults = 0; if($productlist != ""){ $defaultSearchTitle = "Additional search results for: "; echo "

Products related to your search: $busca

"; echo $productlist; $weHaveResults = 1; } if($defaultCount>0){ echo "

$defaultSearchTitle $busca

"; echo $resultadosDefault; $weHaveResults = 1; } if ($weHaveResults == 0){ echo '

Nothing Found for '.$busca.'

Sorry, but nothing matched your search criteria. Please try again with some different keywords.

'; } ?>