Home › Toolset Professional Support › [Resolved] Views plugin custom search with ajax stopped working
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
Tagged: Custom search, Views plugin
Related documentation:
This topic contains 42 replies, has 2 voices.
Last updated by Nicholas 6 years, 10 months ago.
Assisted by: Nigel.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
You create a custom archive and then assign it to products.
That custom archive will then be shown on the page which is assigned by WC as the shop page (provided your settings in Toolset > WooCommerce Views say to use the WooCommerce Views PHP template for the product archive).
Yes I did that. The archive is called "Product Archive".
However the problem doesn't go away if I do that.
See for yourself
hidden link
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Nick,
I looked again at your site and went to see how you custom archive was set up at Toolset > WordPress Archives and there are none.
You need to create a custom archive and to assign it to the product archive. If you want to use Layouts, you create the custom archive then insert it into a Layout using an archive cell, and then assign the Layout to the product archive.
Hm....yes this works.
But what if I don't want to create a custom archive?
I'd rather make use of the already existing archive.
The way I did it before was: I created a Layout and assigned the Layout to the existing Product Archive, then I added a Content Template to the Layout which has the Custom View inside of it.
Also now I have a header on the custom archive page (see screenshot). How do I get rid of it?
I'd really like to add the custom view inside a content template. Is this not the recommended way to do it?
I feel like I can fully control the design of the page this way.
Hope this makes sense.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Nick
This is the correct way to do it. WordPress has the concept of archives that correspond to particular URLs and for which WordPress will run the corresponding query to generate the appropriate list of posts.
When you assign a Views custom archive to a particular archive it will modify the corresponding query according to the settings you specify.
If you are using Layouts and assign a Layout which contains an archive cell to an archive the results are basically the same.
If you are using Layouts and assign a Layout to an archive but do not include an archive cell, WordPress will still run the (unmodified) query to generate the relevant list of posts, you just won't be using them. If you add a View to the Layout, then you are adding another query in addition to the archive query that is already running.
Not only is that inefficient, but when you add WooCommerce to the mix, it and its many extensions expect a product archive query to be operative on the shop page, and by omitting it you can expect things to start breaking.
Now, you then have the issue of the header on your archive page.
You are using the Toolset Starter Theme (which we now discourage for everyone but users who have a strong case for using it). So you can create Layouts with no header/footer.
I'm guessing that you created a custom archive and assigned it to the product archive directly.
You should be able to create a Layout, assign it to the product archive, then insert your custom product archive into your Layout using an archive cell, and omit a header and footer from your Layout.
If you do that do you get the desired result?
Thank you so much for your thorough explanation Nigel. I understand the concept of wordpress archives a lot better now. I'll test it out and then get back to you.
Also I know this might be outside of this support ticket but since you mentioned it what's wrong with the Toolset Starter Theme/Toolset Starter Child Theme and why do you discourage using it?
What themes do you guys recommend? I really like those because they are very lightweight. I basically need a very lightweight, SEO friendly theme.
So I tested it thoroughly.
The AJAX filter works on the product archive now, however now the sorting is not accurate anymore. Even though I replicated the view 1:1.
I have a sorting control in place called _upvote_count. It sorts the products based on the most upvotes in a descending order.
This sorting control and 3 other sorting controls stopped sorting the products in a descending order based on the nurmeric value of the custom field on the new custom archive page/woocommerce shop page compared to the old view.
I compared the URL of the old view on regular page vs the archive on the shop page and noticed the following. I tested it with the _upvote_count custom field sorting control.
Regular page with old view: ?wpv_aux_current_post_id=609&wpv_sort_orderby=field-_upvote_count&wpv_sort_order=desc&wpv_view_count=197-TCPID609
New archive page/woocommerce shop page: ?wpv_post_search&wpv_sort_orderby=field-_upvote_count&wpv_view_count=608
Why are the URL parameters so different?
And why is the sorting not accurate anymore even though I replicated the view 1:1?
You can check it out yourself on these pages:
Custom Archive/WC Shop: hidden link
vs
Regular page with custom view: hidden link
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Nick
The Toolset Starter Theme has various limitations, such as if you use Layouts you need to use it on every page, you can't choose to use it on some and not others, and it was decided that rather than develop the theme further our resources could be better utilised adding/maintaining support for a few themes popular with developers (we asked for suggestions).
For simple starter themes, try Ocean WP, Astra, or Generate Press (https://toolset.com/documentation/recommended-themes/).
You lose the ability to design the whole page, including header and footer, but you also lose the requirement to do so, and with these themes you can set theme options, such as whether to display a sidebar, for each template, with different settings possible for different pages.
I'm just looking into the sorting issue now and will get back to you...
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Nick
I just ran some tests and it worked as expected for me, setting the Ordering options on my custom product archive to use a custom field to order by, using the front-end sorting controls updating with Ajax.
Regarding which URL parameters are included or not, it seems that parameters are only added where they are needed to override the default (set in the Ordering option of the The Loops Selection section).
There are only two reasons I can think of why it might not work for you.
The first is that in Toolset > WooCommerce Views in the settings there is an option to use default WooCommerce front-end sorting, which should be unchecked.
The second is how your _upvotes custom field is stored (I don't know what generates it). In my testing I used a simple numeric field to store the number of updates. If your _upvotes field is stored in some other way, e.g. an array, it won't give meaningful results when sorting.
Can you inspect the database and see how the _upvote custom field is stored for one of your product posts?
Hey thanks Nigel for the clarification. I didn't know that about the toolset starter theme. Will you eventually take these themes down? or what does that mean in terms of the future?
So with other themes I couldn't change/design the header and footer? This is only possible with the toolset starter theme?
Actually meta value is in long text type and storing value is numbers
You said "..Toolset > WooCommerce Views in the settings there is an option to use default WooCommerce front-end sorting, which should be unchecked."
Do you mind sending a screenshot? I can't find this option.
Also why do I get accurate results on this page hidden link using the custom view but not on the WC shop page hidden link
Custom Archive/WC Shop: hidden link
vs
Regular page with custom view: hidden link
Do you notice the differences in the output?
Thanks for you help.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Nick
I tried to install Query Monitor on your site because I wanted to inspect the queries on the archive page to see why the sort order isn't behaving as expected but it seems like you have a security layer preventing that.
So I tried to make a duplicate to test locally, but duplicator can't create packages.
Can you help me out here?
Regarding the themes, Toolset Starter Theme will be maintained for bug fixes, but won't otherwise be developed. Most themes have options for customising the header and footer, but what exactly you can do depends on the individual theme.
Hey Nigel.
Sorry this issue is now fixed. You can create duplicator packages now. I went ahead and created one for you. You can download it directly from the site.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Nick
I took a local copy, did some more testing, confirmed the issue, and I am in fact now able to reproduce on a test site.
The front-end ordering controls simply don't work on a custom product archive.
I have escalated the issue to be investigated further and I'll keep you posted.
Thanks for your patience.
Hi Nigel.
Interesting that the front-end ordering controls don't work on a custom product archive.
Has this issue been reported before?
Thanks for keeping me updated.