Skip Navigation

[Gelöst] Broken sorting after click on Submit Btn or AJAX sort

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem: I'm trying to use sorting on an AJAX view, but the sort order doesn't work after I click the submit button.

Solution: In this case, the Post Order plugin was causing conflicts with Views' ordering. Disable the Post Order plugin to fix the problem.

This support ticket is created vor 5 Jahren, 11 Monaten. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von cassianS vor 5 Jahren, 11 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#1179417
ToolsetSearch_Settings.jpg

I am trying to:
- to keep predefined sort options, when I sort products in a specific way. Therefore, when I use a filter, products should be still sorted as defined. For sorting, I use a custom (Number) field for a full sort control.

Instead, I got:
- Instead, products are sorted randomly
After I tested different sort settings options I found that sort brokes always, when I chose options without page reloading. (Screenshot of an example of settings when I observe an issue you can find in the attachment)

Link to a page where the issue can be seen:
versteckter Link

#1179461
Screen Shot 2019-01-07 at 5.43.50 PM.png

Hi, can you try the following troubleshooting steps first?
- Temporarily switch to a default theme like Twenty Seventeen or Twenty Nineteen. Deactivate all plugins except Types and Views. If you want to activate a Maintenance Mode plugin for testing, that's fine.
- Test again. If sort is working as expected, reactivate your parent theme, then child theme, then other plugins, one by one until the problem returns. Try to isolate a single component that is causing this conflict.
- If the sort is still not working as expected, check the Ordering settings for this View and confirm that you are sorting as a number, not a string or native custom field. Screenshot attached.

Please let me know the results of these tests.

#1180289

Hi Christian.
Thank you for your advice.
I tested with deactivation of plugins and changing themes. I have found that issue with a sort appears when I activate
Post Types Order plugin: https://wordpress.org/plugins/post-types-order/

I used this plugin to change an order of posts and the way how users move from post to post using "Previous/Next" links (in the single post). Page link here: versteckter Link
Previously, without that plugin, even if I used alphabetic sort from Toolset, "Previous/Next" would lead not to the previous or next post (by alphabetic sort), but to posts with a higher/lower post ID.

If I can't use the Post Types Order plugin, what another solution you could suggest?
Thank you

#1180369
query-filter-1.png

I don't know of a simple solution to create next and previous post links automatically based on alphabetical order of post titles. That would require some fairly complex custom code. However, if you have a numeric custom field set up already for determining sort order, you could use that field with Views to display custom "Next" and "Previous" links instead.
- Create a View and choose "Full custom display" in the popup. This View will display your "previous" post link, so name it something relevant.
- Choose this post type in the Content Selection area.
- Order the View by your sorting custom field, as a number, in descending order.
- Check "Don't include current page in query result".
- Set a limit of 1 post, with no offset.
- Add a Query Filter, filtered by the custom field, as a number, where the results are lower than or equal to a shortcode attribute "current" (see query-filter-1.png).
- In the Loop editor, click "Skip wizard" to skip the Loop Wizard tool. Insert a post title with link shortcode inside the wpv-loop tags. You can add some text that says "Previous post: " or whatever you want to say before the wpv-post-link shortcode.
- Remove all the content from the no items found section.
- Insert this View in your post template and add the "current" shortcode attribute. Set the value of the current attribute using the raw custom field value from the current post, like this:

[wpv-view name="Your View Name" current="[types field="your-order-field-slug" output="raw"][/types]"]

- Repeat this process to create a second View that will be used to display the "next" post link. In this View, use ascending order instead of descending order, and set the Query Filter to be greater than or equal to the shortcode attribute "current".
- Insert this View in your post template and add the "current" shortcode, just like you did with the other View.

Let me know if you run into problems and I can take a closer look.

#1180913

My issue is resolved now. Thank you very much, Christian!