Skip Navigation

[Gelöst] Split: Can't Add Field to View – sort terms in specific order for taxonomy filter

This support ticket is created vor 6 Monate, 2 Wochen. 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.

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 12 Antworten, has 2 Stimmen.

Last updated by Minesh vor 6 Monate.

Assisted by: Minesh.

Author
Artikel
#2652143

Well, it works, thank you, Minesh. I don't understand why you used Bootstrap, can you explain? I don't know how to edit Bootstrap files, for instance, I've got a background on all breadcrumbs and I don't want it.

Also, how do I get this tax in numerical order?

Thanks.

#2652147

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can not order terms with it has text and number as term name. You may add a custom term field that should be used to hold the number (order number) and we can use that number to sort the terms later on.

Here is the doc that shows how you can add term fields:
- https://toolset.com/documentation/term-fields/

#2652893

Not quite sure what you mean by "can not order terms with it has text and number as term name."

#2653213

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

You have term names like (Up to 2, Up to 4, Up to 6 etc..etc) which is added as alpha numerical and we can not order it numerically.

That is why I asked you to add a custom number as term meta field to your taxonomy and set each term order you would like and then I will help you to display the terms in that order.

Here is the doc that shows how you can add term fields:
- https://toolset.com/documentation/term-fields/

#2653485
Screen Shot 2023-10-16 at 8.21.17 PM.png

Oh, Minesh, I'm sorry, but...

So far I've got this, but don't know where to go from here. I do have this page: https://toolset.com/documentation/displaying-wordpress-term-fields/

#2653617

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

You should have one number field that should hold the term order number.

I've removed all the fields you created and added the "Guest Term Order" custom number field with the following custom term field group:
- hidden link

Now, when you edit any Guest term, you will see a field "Guest Term Order" where you should add the order number in what order you want to display that specific taxonomy term. You should edit every term and set the order number with the field "Guest Term Order".
- hidden link

Once you set the order number please let me know and we will try to display the terms as per the order number you set with the custom term field "Guest Term Order".

#2653869

I don't see "Guest Term Order" anywhere, sorry.

#2653947

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Here is the edit link to edit one of the term:
- hidden link

Once you scrolldown a bit you will see the field "Guest Term Order" where you should add the order number you want to display that specific term in that order.

You should edit all the terms likewise and set the term order number with the field "Guest Term Order" once you set the order number for all term you should get back to me.

#2655615

Okay, I did it, here: hidden link

Now what? I am utterly clueless, sorry.

#2655651

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

The filter hook I've added to "Custom Code" section offered by Toolset does not work.

I will have to try to add the filter hook to your theme's functions.php file and check if that works.

For that - I will require FTP access details.

Can you please send me working FTP/SFTP access details.

I have set the next reply to private which means only you and I have access to it.

#2656779

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can add the following filter to "Custom Code" section offered by Toolset with the code snippet "set-taxonomy-filter-term-order":
=> hidden link

add_filter( 'wpv_filter_taxonomy_frontend_search_get_terms_args', 'func_tax_filter_term_order', 10, 3 );
function func_tax_filter_term_order( $args, $taxonomy, $view_id ) {
 
  $allowed_view_ids = array(29575);
 
  if (in_array($view_id, $allowed_view_ids ) and $taxonomy=='guest') {
        
        $args['meta_key'] = array('key' => 'wpcf-guest-term-order');
        $args['orderby'] = 'meta_value_num';
     	$args['order'] = 'ASC';    
    
   }
     
    return $args;
}

I can see now terms are displayed in mentioned order:
- hidden link

You should add the order for every term so that the filter should display all terms.

#2657813

Hi Minesh. The custom code section works, but it only goes up to up to 16. My Guests tax goes to 32.

#2658353

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

When I see the taxonomy term list:
- hidden link

I see you did not set the order number for many terms. Can you please set order for each and every term.

Also, please note that - the taxonomy filter dropdown will only display the terms that are available with the result.

#2658637

Oh, Minesh, thank you SO much. I just couldn't wrap my head around this, and now - it works! You're my hero.

suzyo confirmed that the issue was resolved on 2023-10-30 22:40:24.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.