Forums Forums Search & Filter Pro Can't show search results on specific page

Viewing 10 posts - 1 through 10 (of 16 total)
  • Anonymous
    #76191

    I purchased Search&Filter Pro, the issue is when I choose to show results on some page I created, it works fine, but when I want to show on default Search Page, results don’t appears.
    It works with shortcode on custom page, also I put shortcode at Search Page, I see Ajax is working but it continue showing me all the posts.
    I am using Reviews Theme => https://themeforest.net/item/reviews-products-and-services-review-wp-theme/13004739?s_rank=4
    It also work as Post Type Archive, and when I change that Search Page be a Page for Post(Blog), remain the same, it shows all posts.
    I’m not so familiar with WordPress Loop, but probably there is a catch…

    Trevor
    #76237

    Can you show me the search page URL, and what display results method is it set to at the moment?

    Anonymous
    #76255

    I’m doing on localhost yet…
    http://localhost/wordpress/search-page/

    and this is code template for Search Page..
    <?php
    /*
    Template Name: Search Page
    */
    get_header();
    the_post();

    global $reviews_slugs;

    $review_category = isset( $_GET[$reviews_slugs[‘review-category’]] ) ? esc_sql( $_GET[$reviews_slugs[‘review-category’]] ) : ”;
    $review_tag = isset( $_GET[$reviews_slugs[‘review-tag’]] ) ? esc_sql( $_GET[$reviews_slugs[‘review-tag’]] ) : ”;
    $keyword = isset( $_GET[$reviews_slugs[‘keyword’]] ) ? esc_sql( $_GET[$reviews_slugs[‘keyword’]] ) : ”;
    $sort = isset( $_GET[$reviews_slugs[‘sort’]] ) ? esc_sql( $_GET[$reviews_slugs[‘sort’]] ) : ”;

    $base_permalink = reviews_get_permalink_by_tpl( ‘page-tpl_search’ ) ;
    $permalink = reviews_get_permalink_by_tpl( ‘page-tpl_search’ ) ;

    $args = array(
    ‘post_type’ => ‘review’,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => reviews_get_option( ‘reviews_per_page’ ),
    ‘tax_query’ => array(
    ‘relation’ => ‘AND’
    ),
    ‘meta_query’ => array(
    ‘relation’ => ‘OR’
    )
    );

    $category_ancestors = array();
    if( !empty( $review_category ) ){
    $permalink = add_query_arg( array( $reviews_slugs[‘review-category’] => $review_category ), $permalink );
    $args[‘tax_query’][] = array(
    ‘taxonomy’ => ‘review-category’,
    ‘field’ => ‘slug’,
    ‘terms’ => $review_category,
    );
    $term = get_term_by( ‘slug’, $review_category, ‘review-category’ );
    $description = $term->description;
    $category_ancestors[] = $term->term_id;
    while ( $term->parent != 0 ){
    $term = get_term_by( ‘id’, $term->parent, ‘review-category’ );
    $category_ancestors[] = $term->term_id;
    }
    }

    if( !empty( $review_tag ) ){
    $permalink = add_query_arg( array( $reviews_slugs[‘review-tag’] => $review_tag ), $permalink );
    $args[‘tax_query’][] = array(
    ‘taxonomy’ => ‘review-tag’,
    ‘field’ => ‘slug’,
    ‘terms’ => $review_tag,
    );
    }

    if( !empty( $keyword ) ){
    $permalink = add_query_arg( array( $reviews_slugs[‘keyword’] => $keyword ), $permalink );
    $args[‘s’] = $keyword;
    }

    if( !empty( $sort ) ){
    $sort_array = explode( “-“, $sort );
    $args[‘order’] = $sort_array[1];
    if( $sort_array[0] == ‘title’ || $sort_array[0] == ‘date’ ){
    $args[‘orderby’] = $sort_array[0];
    }
    else{
    $args[‘orderby’] = ‘meta_value_num’;
    $args[‘meta_key’] = $sort_array[0];
    if( $args[‘meta_key’] == ‘clicks’ ){
    $args[‘meta_key’] = ‘review_clicks’;
    }
    }
    }

    $cur_page = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; //get curent page
    $args[‘paged’] = $cur_page;
    $reviews = new WP_Query( $args );
    $page_links_total = $reviews->max_num_pages;
    $page_links = paginate_links(
    array(
    ‘prev_next’ => true,
    ‘end_size’ => 2,
    ‘mid_size’ => 2,
    ‘total’ => $page_links_total,
    ‘current’ => $cur_page,
    ‘prev_next’ => false,
    ‘type’ => ‘array’
    )
    );
    $pagination = reviews_format_pagination( $page_links );

    ?>

    <section class=”search-filter”>
    <div class=”container”>
    <div class=”row”>
    <div class=”col-sm-4″>
    <div class=”widget white-block clearfix”>

    <div class=”widget-title-wrap”>
    <h5 class=”widget-title”>
    <i class=”fa fa-angle-double-right”></i><?php esc_html_e( ‘Filter po ključnoj reči’, ‘reviews’ ); ?>
    </h5>
    </div>
    <form method=”get” action=”<?php echo esc_url( $base_permalink ) ?>”>
    <input type=”text” class=”form-control” name=”<?php echo esc_attr( $reviews_slugs[‘keyword’] ); ?>” value=”<?php echo esc_attr( $keyword ) ?>” placeholder=”<?php esc_attr_e( ‘Unesi termin i pritisni enter…’, ‘reviews’ ); ?>”>
    </form>

    </div>
    </div>
    <div class=”col-sm-4″>

    <div class=”widget white-block clearfix”>

    <div class=”widget-title-wrap”>
    <h5 class=”widget-title”>
    <i class=”fa fa-angle-double-right”></i><?php esc_html_e( ‘Filter po Kategoriji’, ‘reviews’ );?>
    </h5>
    </div>
    <form method=”get” action=”<?php echo esc_url( $base_permalink ) ?>”>
    <select name=”<?php echo esc_attr( $reviews_slugs[‘review-category’] ); ?>” id=”review-category” class=”form-control”>
    <option value=””><?php esc_html_e( ‘Sve Kategorije’, ‘reviews’ ) ?></option>
    <?php reviews_display_categories_filter( $category_ancestors, $permalink ) ?>
    </select>
    </form>

    </div>
    </div>
    <div class=”col-sm-4″>
    <div class=”widget white-block clearfix”>

    <div class=”widget-title-wrap”>
    <h5 class=”widget-title”>
    <i class=”fa fa-angle-double-right”></i><?php esc_html_e( ‘Sortiraj Utiske’, ‘reviews’ );?>
    </h5>
    </div>
    <form method=”get” action=”<?php echo esc_url( $base_permalink ) ?>”>
    <select name=”<?php echo esc_attr( $reviews_slugs[‘sort’] ); ?>” id=”sort” class=”form-control”>
    <option value=””><?php esc_html_e( ‘- Izaberi -‘, ‘reviews’ ) ?></option>
    <option value=”author_average-desc” <?php echo $sort == ‘author_average-desc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Po autoru (najviše prvo)’, ‘reviews’ ) ?></option>
    <option value=”author_average-asc” <?php echo $sort == ‘author_average-asc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Po autoru (najmanje prvo)’, ‘reviews’ ) ?></option>
    <option value=”user_average-desc” <?php echo $sort == ‘user_average-desc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Po korisniku (najviše prvo)’, ‘reviews’ ) ?></option>
    <option value=”user_average-asc” <?php echo $sort == ‘user_average-asc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Po korisniku (najmanje prvo)’, ‘reviews’ ) ?></option>
    <option value=”date-desc” <?php echo $sort == ‘date-desc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Datum (skorašnji prvo)’, ‘reviews’ ) ?></option>
    <option value=”date-asc” <?php echo $sort == ‘date-asc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Datum (stariji prvo)’, ‘reviews’ ) ?></option>
    <option value=”title-desc” <?php echo $sort == ‘title-desc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Naziv (opadajuče)’, ‘reviews’ ) ?></option>
    <option value=”title-asc” <?php echo $sort == ‘title-asc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Naziv (rastuće)’, ‘reviews’ ) ?></option>
    <option value=”clicks-desc” <?php echo $sort == ‘clicks-desc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Pregleda (opadajuće)’, ‘reviews’ ) ?></option>
    <option value=”clicks-asc” <?php echo $sort == ‘clicks-asc’ ? esc_attr( ‘selected=”selected”‘ ) : ” ?>><?php esc_html_e( ‘Pregleda (rastuće)’, ‘reviews’ ) ?></option>
    </select>
    <?php if( !empty( $review_category ) ): ?>
    <input type=”hidden” name=”<?php echo esc_attr( $reviews_slugs[‘review-category’] ); ?>” value=”<?php echo esc_attr( $review_category ) ?>”>
    <?php endif; ?>
    <?php if( !empty( $review_tag ) ): ?>
    <input type=”hidden” name=”<?php echo esc_attr( $reviews_slugs[‘review-tag’] ); ?>” value=”<?php echo esc_attr( $review_tag ) ?>”>
    <?php endif; ?>
    <?php if( !empty( $keyword ) ): ?>
    <input type=”hidden” name=”<?php echo esc_attr( $reviews_slugs[‘keyword’] ); ?>” value=”<?php echo esc_attr( $keyword ) ?>”>
    <?php endif; ?>
    </form>

    </div>
    </div>
    </div>
    <div class=”row”>
    <div class=”col-sm-<?php echo is_active_sidebar( ‘reviews-search’ ) ? esc_attr( ‘9’ ) : esc_attr( ’12’ ) ?>”>
    <?php
    if( !empty( $description ) ){
    ?>
    <div class=”white-block”>
    <div class=”content-inner category-description”>
    <?php echo $description ?>
    </div>
    </div>
    <?php
    }
    ?>
    <?php if( $reviews->have_posts() ): ?>
    <div class=”row masonry”>
    <?php
    while( $reviews->have_posts() ){
    $reviews->the_post();
    echo ‘<div class=”col-sm-‘.( is_active_sidebar( ‘reviews-search’ ) ? esc_attr( ‘6’ ) : esc_attr( ‘4’ ) ).’ masonry-item”>’;
    include( reviews_load_path( ‘includes/review-box.php’ ) );
    echo ‘</div>’;
    }
    ?>
    </div>
    <?php if( !empty( $pagination ) ): ?>
    <div class=”pagination”>
    <?php echo $pagination; ?>
    </div>
    <?php endif; ?>
    <?php else: ?>
    <div class=”widget white-block”>
    <?php esc_html_e( ‘Nema utiska po zadatom kriterijumu…’, ‘reviews’ ); ?>
    </div>
    <?php endif; ?>
    </div>

    <?php get_sidebar( ‘reviews-search’ ); ?>
    </div>
    </div>
    </section>

    <?php get_footer(); ?>

    Trevor
    #76305

    If you try the Custom method and add into the args array something like:

    'search_filter_id' => 1234,

    Does that work? (the last array item in the args array does not have a comma after it, all others do.)

    Anonymous
    #76397

    Yes. It works like that!
    Thanks a lot.
    I have another Question..
    Is it possible for some of Post Meta to exclude from Filter for some Subcategory..
    I want to have one filter and then to change Post Meta for certain subcategory…
    Is it possible is there that option in plugin?

    Trevor
    #76541

    You would have to give me examples, but be wary of using a taxonomy/category more than once in the form, and multiple parent/child hierarchies are likely to cause problems. If this is what you are trying to do, I can help rework it.

    Anonymous
    #76576

    For example I have category Tehnics and Subcategory Laptops and LCD TV.
    My Search&Filter form has post meta Hard Disk that use Data from ACF Custom Field.
    I want to show that post meta only on Laptops Subcategory…
    Is it possible?
    To have one filter and choose what post meta to show depends on Subcategory…
    Thanks.

    Trevor
    #76592

    Normally, you would have two taxonomies; one for the higher level and one for the sub level. Search filter can make options appear or hide depending on the top level choice. I know that this is on localhost, but I really need to see what you have made already, somehow.

    Anonymous
    #77026

    I have created Search & Filter search form like on image bellow:
    search filter
    And I want to show/hide Post Meta: reviews_score for Laptops Subcategory or any other Sucbategory…
    Or any other Post Meta Fields that I have in my Search Form UI to be able to show/hide depends od Subcategory…
    Is it possible with this plugin?

    Anonymous
    #77028

    sf

Viewing 10 posts - 1 through 10 (of 16 total)