Forums › Forums › Search & Filter Pro › Taxonomy not working for custom post type
- This topic has 7 replies, 3 voices, and was last updated 7 years, 11 months ago by Anonymous.
-
Anonymous(Private) December 14, 2016 at 9:21 pm #76399
Hello!
I’ve been testing Search & Filter Pro with a custom post type. Ajax seems to work correctly while using a regular search text and/or using Sort Order, but when I use a Taxonomy, ajax doesn’t work. I’ve looked over the code and added some console.log/echo/print_r checks in order to find out where the issues were happening. In looking at the Ajax URL, there are a number of WP_Errors, mostly pointing to the slug and term_d, both found in the class-search-filter-cache.php file. When writing out the error, I am seeing an “Invalid taxonomy” message. I haven’t done anything special, I am using the default results display with the display results method being: “Using a Shortcode”.
Here’s one of the error messages:
Notice: Undefined property: WP_Error::$slug in C:\xampp\apps\wordpress\htdocs\wp-content\plugins\search-filter-pro\public\includes\class-search-filter-cache.php on line 385
Can you give me any insight into what might be going on?
As a side note, I am currently running this on localhost.
Thanks!
Josh
Ross Moderator(Private) December 20, 2016 at 5:06 pm #77856Hey Josh
Sorry for the delay on this..
So I took a look and makes sense.
As you mentioned, it seems like the taxonomy may not be initialised properly – can I ask, how is this taxonomy created and on what action/filter is it hooked onto?
I believe taxonomies should be added on the
init
action – which should work for S&F ajax requests like this..BTW have you done anything at all to the search form, such as add on JS that styles the search form, or even edited any plugin files?
I guess you already came to the same conclusion which is that it looks like our JS is not finding a HTML element it expects to be there (within the ajax request), and this is because the taxonomy is not initialised yet so the html is not generated.
BTW if you add
define("SEARCH_FILTER_DEBUG", true");
to your wp-config so we will be using the uncompressed JS files so we can get a better idea of exactly where the JS error is coming from.Thanks
Anonymous(Private) December 20, 2016 at 7:56 pm #77901Ross,
No worries on the delay. I appreciate you taking the time to look into it.
After doing some looking, I was able to track down the issue. In my initial research, it seemed that the issue was related to
init
, but I wasn’t sure. After I was able to find the action hook and change it to init, everything worked correctly.I had made a number of changes in S&F at first, writing out values to track things down. I logged the ajax URL to the console window and was then able to see the errors that related to the taxonomy not being valid. This lead me to the
init
issue. I had made the wp-config changes locally, so I was able to test locally, just forgot when I pushed everything to the test site.The code that was on the test site had not been changed. I think the JS error was due to the errors that were being returned in the ajax call. The errors prevented the JSON from formatting correctly, which caused the error.
I really appreciate all of your help, and feel bad that I wasted your time.
If you need anything from me (review, etc…), please let me know.
Have a great rest of your week.
Have a Merry Christmas and a Happy New Year!
Thanks,
Josh
Trevor(Private) December 21, 2016 at 9:53 am #77966Hey Josh. Happy Holidays to you too!!
Can I close this thread as resolved?
and the review page is here:
http://www.designsandcode.com/wordpress-plugins/search-filter-pro/reviews/#comment
-
AuthorPosts