Skip Navigation

[Resolved] Allow for tags to be ordered by order added, not in alphabetical order in a view

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 10 replies, has 2 voices.

Last updated by philipS-3 1 year, 2 months ago.

Assisted by: Minesh.

Author
Posts
#2550287

Tell us what you are trying to do?

I have a cpt to highlight certain research journal articles. The custom cpt comes with a dedicated tag style taxonomy for the journal article authors. For the custom cpt I use a toolset view to display the date. Unfortunately, when setting up the view, I can only select to show the authors in alphabetical order (ascending or descending). However, I need to be able to retain the original author structure.

Is there any documentation that you are following?

It seems like a general wordpress / gutenberg issue to some degree, but as discussed here, hidden link the order of tags added is registered in the database so technically it should be possible to for it to retain the order?!

Is there a way to get the tags (in my case the author names) show up in the right and thus non-alphabetical order?

Kind regards, Philip

#2550871

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Let me review if I can offer you any workaround or is there is possible solution to your issue and for that I will require problem URL where I can see the issue as well as admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

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

#2551005

Minesh
Supporter

Languages: English (English )

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

You are right - the access details were not required in this case, if you have shared the screenshot with your initial post.

Maybe it will require custom shortcode to display the terms in your case.

What if you try to use the following shortcode - you can add the following shortcode to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset

function func_show_terms_term_order($atts) {
    global $post;
       
       
    $taxonomy = $atts['taxonomy']; // change this to your taxonomy
    $separator = $atts['separator'];
    $terms = wp_get_object_terms( $post->ID, $taxonomy, array( "fields" => "ids", "orderby"=>"term_order") );
    if( $terms ) {
        $terms = trim( implode( ',', (array) $terms ), ' ,' );
        return rtrim(trim(wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms."&hierarchical=0"."&separator=".$separator."&echo=0&style=none")),'/ ');
           
    }
}
add_shortcode('show_terms_term_order', 'func_show_terms_term_order');

You can call the shortcode as given under:

[show_terms_term_order  taxonomy="category" separator=" , "]

Where:
- Replace the "category" with your original taxonomy slug.

Can you please try above solution and check if that helps you to resolve your issue.

#2551177

Dear Minesh,

So I tested your code with both a core and cpt taxonomy and it doesn't work. Here's what I am seeing:

When I include the shortcode without the code snippet being activated: It just shows the shortcode on the front end

When I activate the code snippet without the taxonomy specified: I see the correct print of the taxonomy called for with the shortcode, but with the same alphabetical order like in the original

When I include the taxonomy in the code snippet: Everything disappears, nothing is printed on the front end

In Debug.php I then get the following message:

[09-Feb-2023 16:21:35 UTC] PHP Notice: Undefined index: key-feature in /var/www/web124/htdocs/FSLCITest/wp-content/toolset-customizations/ordertax.php on line 14

key-feature in this case is the slug for my taxonomy.

Let me know if there's anything I can do to further debug.

Kind regards, Philip

#2551569

Minesh
Supporter

Languages: English (English )

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

Can you please share details on what page you are testing this and I'm happy to look at whats going wrong there.

#2551799

Dear Minesh,

You can use the login provided earlier and then test your code yourself. I have tested it based on the CPT "Tools", for which you can edit the content template here: hidden link

The corresponding front-end test post is called "Test Entry" and visible here: hidden link

Kind regards, Philip

#2553309

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

I've adjusted the code added to "Custom Code" section as given under:

function func_show_terms_term_order($atts) {
    global $post;
        
        
    $taxonomy = $atts['taxonomy']; // change this to your taxonomy
    $separator = $atts['separator'];
    $terms = wp_get_object_terms( $post->ID, $taxonomy, array('fields'=>'ids', "orderby"=>"term_order") );
  
  
    if( $terms ) {
        $terms = trim( implode( ',', (array) $terms ), ' ,' );
        return rtrim(trim(wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms."&hierarchical=0"."&separator=".$separator."&echo=0&style=none&orderby=term_order")),'/ ');
            
    }
}
add_shortcode('show_terms_term_order', 'func_show_terms_term_order');

Can you please confirm it works as expected now.

#2553543

Dear Minesh,

Thanks so much for the revision. Indeed, it does work on the dev site now, which is awesome. However, for some reason beyond my understanding, I can't get it to work on my live site.

The main issue is that on the live site, the shortcode is not resolving, even before I activate the custom code to change the order. I copied it over from the test site and changed the taxonomy, it just displays the shortcode on the front end. Equally so, if I change the taxonomy to another one, or enter the code directly into an entry instead of the content template.

Here you can see that it's not working: hidden link

If I activate the code snippet, then the shortcode disappears on the front end but then nothing is shown. Any idea what might be causing the issue? I don't understand why it's working on my dev but not on my live env.

Kind regards, Philip

#2553549

Minesh
Supporter

Languages: English (English )

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

I can see the shortcode is not get rendered. Did you activated the snippet? if yes:
I'm not sure whats going wrong with your setup.

I'll require admin access details to check whats going wrong with your seutp.

*** Please make a FULL BACKUP of your database and website.***
I have set the next reply to private which means only you and I have access to it.

#2553559

Dear Minesh,

Ok, I figured out what the issue was: In your code snippet you still had "// change this to your taxonomy" but then left it as a general call to "taxonomy" in the actual code - which I didn't see until a moment ago. Now, if I leave it as taxonomy and don't change it, then the shortcode is properly resolved 🙂

However, now I've run into another, more layout related issue:

The items now appear stacked instead of in a list as you can see here: hidden link

Not sure why, but that doesn't look great. Also, I would like to include "Author:" before the shortcode is displaying the authors - essentially I want to replace the fields I'm already showing now below but with the correct order of authors 🙂

Your support is greatly appreciated!

Kind regards, Philip

P.S. I can't give you access to the live site due to Data Protection issues...

#2553571

I solved it myself by using the Fields and Text Field to include the "Author:" text and now it's displayed also in a list as I wanted. Thanks so much for your support, much appreciated 🙂

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.