Hi everyone in the forum, i keep on trying to page the search with the plugin using as i wrote the categories. I have tryed to re-adapt the facetedsearch_smart_query function but i am getting lost cuz no results are diplayed or not paged even when the array contains the $pageposts. Not even a clue with the pagination.
Could any one give me a clue?
Thanks in advanced:
Here is the function code modified:
function facetedsearch_smart_query($effective_array, $descendant_array)
{
global $wpdb;
$query = ‘SELECT DISTINCT * ‘;
$queryfrom = ‘FROM ‘.$wpdb->posts;
$querywhere = ” WHERE post_type = ‘post’ AND post_status = ‘publish’ “;
$siblings = $_POST[‘taxonomy’];
$indexes = array();
foreach ($siblings as $clave => $valor)
{
if ($valor == 0)
{
array_push($indexes, $clave);
}
}
foreach ($indexes as $clave => $valor)
{
//generar los arrays dinamicamente
${$indexes.$valor} = array();
}
foreach ($effective_array as $clave => $valorefectivo)
{
$cat_name = get_category_parents($valorefectivo,false,’ » ‘);
$category->name = substr($cat_name ,0, strpos($cat_name,’ » ‘) );
$id= get_term_by(“name”,$category->name, “category”);
$id = $id->term_id;
array_push(${$indexes.$id}, $valorefectivo);
}
foreach ($indexes as $clave => $valor)
{
if ( count(${$indexes.$valor}) > 0 ){
$querywhere .= ‘AND (‘;
$querywhere .= facetedsearch_simple_query(${$indexes.$valor},null,”OR”);
$querywhere .= ‘)’;
}
}
$querywhere .= ‘ ORDER BY post_date DESC’;
$query = $query.$queryfrom.$querywhere;
$totalevents = $wpdb->get_results( $query, OBJECT );
$ppp = intval( get_query_var( ‘posts_per_page’ ) );
$wp_query->found_posts = count( $totalevents );
$wp_query->max_num_pages = ceil( $wp_query->found_posts/$ppp );
$on_page = intval( get_query_var( ‘paged’ ) );
if( $on_page == 0 ) { $on_page = 1; }
$offset = ( $on_page-1 ) * $ppp;
$wp_query->request = $query.” LIMIT “.$ppp. ” OFFSET “. $offset;
$pageposts = $wpdb->get_results($wp_query->request, OBJECT);