Saltar navegación

[Resuelto] I can not order by name category on a view

This support ticket is created hace 3 años, 11 meses. 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)

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por Christian Cox hace 3 años, 11 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#1952211

Hi!

I created a view and i cant order by name the categories.

I add the filter:

[wpv-control-post-taxonomy taxonomy="category" type="checkboxes" format="%%NAME%%" class="wpv-category" style="border-radius:40px;" url_param="wpv-category"]

I need to order by name the categories.

Can you help me?

Thank you

#1952605

Hello, it sounds like you want to change the sort order of the category filter terms in a custom search View. The default sort order for a category filter is sorted by term name ASC:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-control-post-taxonomy

So the shortcode you have here seems to be set up appropriately for sorting by term name, in ascending order. If the order is not sorted by name, there could be interference from another theme, plugin, or custom code snippet. As a test, you can try these troubleshooting steps:
- Temporarily activate a default theme like Twenty Twenty one
- Temporarily deactivate all plugins except Types and Views (or Blocks)
- Temporarily deactivate all custom code snippets in Toolset > Settings > Custom Code
- Temporarily deactivate all custom JS code in the View editor screen
- Test again
- If the problem is resolved, reactivate your theme, other plugins, and custom code snippets one by one until the problem returns
- If the problem is not resolved, please provide a URL where I can see the problem

#1953521

Hello Christian,

I modified the code and didnt work:: [wpv-control-post-taxonomy taxonomy="category" type="checkboxes" format="%%NAME%%" order="ASC" orderby="name" class="wpv-category" style="border-radius:40px;" url_param="wpv-category"]

I tried your steps and the problem is not resolved.

- Temporarily activate a default theme like Twenty Twenty one (Not work)
- Temporarily deactivate all plugins except Types and Views (or Blocks) (Not work)
- Temporarily deactivate all custom code snippets in Toolset > Settings > Custom Code (Not work)
- Temporarily deactivate all custom JS code in the View editor screen (Not work)
- Test again

I want order by name categories on checkboxes below 'filtra por sector':

URL: enlace oculto

Thanks!

#1953969

It seems I need a login to see this page. Can you provide login credentials please?

#1954527
Screen Shot 2021-02-17 at 11.47.24 AM.png

Maybe I don't understand the problem? I only see one option in the Category checkboxes filter: "Uncategorized". I also see some JavaScript error on the page:

Uncaught SyntaxError: Identifier 'hide_test' has already been declared

Am I supposed to see more options besides "Uncategorized"?

#1955871

Hi,

Yes, there are more options available.
You entry on english section.

If you switch to spanish section, you will see all options.

#1957103

Okay I see, thank you. The issue here is that Views sorts the filter options from a hierarchical taxonomy based on alphabetic sorting of the top-level terms, and preserves the hierarchy of descendents within those top-level terms. So what you're seeing in the filters now reflects the hierarchical organization you can find in the Categorías page in wp-admin here:
enlace oculto

Unfortunately I don't think there is a simple solution here. I suspect the most practical way to handle this right now is to use custom JavaScript code to manipulate the order of the filter options programmatically when the page loads. Something like this example:
https://www.w3schools.com/howto/howto_js_sort_list.asp