Forums › Forums › Search & Filter Pro › Taxonomies not filtering
Tagged: ajax, custom post types, custom taxonomy, query, url
- This topic has 10 replies, 2 voices, and was last updated 9 years, 5 months ago by Ross.
-
Anonymous(Private) May 20, 2015 at 9:48 pm #17962
My filter form includes filtering by custom taxonomy and post types. The results are correct when the post types are selected, but it just shows all results when I try to filter by a taxonomy term.
When filtering by post type, I do see “?post_types=em_article&sfid=399” appended to the url, but when filtering by taxonomy term I only see “?sfid=399” appended. Also, I have specified the URL to the post/page where the results shortcode can be found, but when I hit submit on the form, the URL query string gets appended to the homepage.
Also, the auto-form-submit is not working.
I have tried switching on and off AJAX, is_search, and other options, but no luck.
Ross Moderator(Private) May 21, 2015 at 12:29 pm #18001Hey Alex can you send me a link to a page with the search form on it?
Thanks
Ross Moderator(Private) May 21, 2015 at 3:07 pm #18031Am I missing something, this page looks blank to me?
Thanks
Anonymous(Private) May 21, 2015 at 4:07 pm #18038I really need to get this working ASAP.
My custom taxonomy terms are showing up, but it looks like they aren’t included in the query. Does this have anything to do with any args in my create taxonomies function in my functions file?
Are there any WP page/search templates that I *need* to include in order for this to work the shortcode way?
Anonymous(Private) May 21, 2015 at 5:43 pm #18050I’ve switched it from shortcode to archive page, and I created a template for this page.
The query at the top of this page is an example from the WP codex:
<?php
global $query_string;$query_args = explode(“&”, $query_string);
$search_query = array();foreach($query_args as $key => $string) {
$query_split = explode(“=”, $string);
$search_query[$query_split[0]] = urldecode($query_split[1]);
} // foreach$search = new WP_Query($search_query);
?>Is there something I should add to this in order for it to add the taxonomy term to the query?
Ross Moderator(Private) May 21, 2015 at 5:59 pm #18052Hi Alex
The shortcode method will probably work best – you weren’t doing anything wrong I don’t htink.
Looking at your source code I can see that for some reason the JS files relating to S&F are not present in the page (the css files are there though… )
If you take a look at the source of the page I would expect that at least
search-filter-plugin-build.js
would be there – but it is not. This is exactly the reason nothing is working.If I take a look at my local installation I see S&F adds this to the source:
<script type='text/javascript'> /* <![CDATA[ */ var SF_LDATA = {"ajax_url":"http:\/\/localhost\/wpsearchandfilter\/wp-admin\/admin-ajax.php","home_url":"http:\/\/localhost\/wpsearchandfilter\/","sfid":"0"}; /* ]]> */ </script> <script type='text/javascript' src='http://localhost/wpsearchandfilter/wp-content/plugins/search-filter-pro/public/assets/js/search-filter-build.js?ver=1.4.3'></script> <script type='text/javascript' src='http://localhost/wpsearchandfilter/wp-content/plugins/search-filter-pro/public/assets/js/chosen.jquery.min.js?ver=1.4.3'></script>
It loads 2 scripts, and initialises some JS variables.
You could try adding these scripts back in manually?
It seems like something is stripping them out of your theme.
To load all S&F js correctly and in the right order you could try using wp_enqueue_script – the code would be something like this:
wp_register_script( 'search-filter-plugin-build', 'http://www.yoursite.com/wp-content/plugins/search-filter-pro/public/assets/js/search-filter-build.js', array('jquery'), '1.4.3' ); wp_localize_script('search-filter-plugin-build', 'SF_LDATA', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'home_url' => (home_url('/')), 'sfid' => '' )); wp_register_script( 'search-filter-chosen-script', 'http://www.yoursite.com/wp-content/plugins/search-filter-pro/public/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.4.3' ); wp_enqueue_script( 'search-filter-plugin-build' ); wp_enqueue_script( 'search-filter-chosen-script' ); wp_enqueue_script( 'jquery-ui-datepicker' );
Obviously remember to update the URLs in there to the correct paths.
Hope that helps!
-
AuthorPosts