A
A
Alexey Vesnin2018-08-22 18:45:23
WordPress
Alexey Vesnin, 2018-08-22 18:45:23

Why is the FacetWP request not working correctly?

Hello. I'm using the facetwp plugin for custom post filtering and sorting.
The code is the following:

<?php
$term_query = get_term_by( 'slug', get_query_var( 'term' ), 'tours_locations' ); 

return array(
     'post_type' => 'tours',
     'publish' => true,
     'posts_per_page' => 50
     'tax_query' => array(
        array(
            'taxonomy' => 'tours_locations',
            'field'    => 'slug',
            'terms'    => $term_query->slug,
        ),
    )
);

If I pass the term dynamically:
$term_query->slug
then the results on the page are displayed normally, but when you select any option in the result filter, 0, while the address bar is substituted with get parameters, and if you refresh the page, the selection will work correctly.
If I pass the term directly like this:
array(
            'taxonomy' => 'tours_locations',
            'field'    => 'slug',
            'terms'    => 'russia',
        ),

then everything works properly and when you select an option in the filter, everything is immediately displayed and not buggy.
What's the catch? when I pass it dynamically, the string is passed as expected.
Plugin: https://facetwp.com/documentation/

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question