Skip Navigation

[Résolu] Hi! I have an issue with alphabetical order using É

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.

Our next available supporter will start replying to tickets in about 2.40 hours from now. Thank you for your understanding.

Marqué : ,

This topic contains 5 réponses, has 2 voix.

Last updated by Luo Yang Il y a 1 an et 5 mois.

Assigned support staff: Luo Yang.

Auteur
Publications
#1611031
Screen Shot 2020-05-04 at 11.30.18 AM.png

Hi! I have an issue with alphabetical order using É

Instead of being used as a «E» it is placed at the end. See image for support; using «E» and using «É». The website is in french so, I must use «É». I'm wondering how to get it fix througt all website. 🙂
THANK YOU!

#1611763

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

order-by.JPG

Hello,

I assume we are talking about a post view, and order by post title, I have tried it in my localhost, it works fine, see screen order-by.JPG, please edit your post view, make sure you are using option: Order by post title Ascending.

In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, and test again

#1612343

Hi, thank you for your response. I appreciate. Those are taxonomy title, or group of posts. They are ordered on a list page or a detailed page like this "[wpv-post-taxonomy type="lieu" separator="  |  " order="asc"]".
Thank you, and have a great day.

#1613265

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Thanks for the details, see our document:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-post-taxonomy
There isn't such kind of built-in feature within shortcode [wpv-post-taxonomy] to sort the result using a "natural order" algorithm.

You can add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Currently, you can setup a custom shortcode to replace it, for example:
1) Add below PHP codes into your theme file functions.php:

add_shortcode('my-post-taxonomy', function($atts, $content){
	$atts = shortcode_atts( array(
		'type' => 'lieu',
		'separator'	=> '  |  ',
		'order'	=> 'asc',
	), $atts);
	
	$res = do_shortcode( sprintf('[wpv-post-taxonomy type="%s" separator="%s" order="%s"]', $atts['type'], $atts['separator'], $atts['order']));
	$arr = explode($atts['separator'], $res);
	if($arr){
		natsort ( $arr );
		if ( $atts['order'] == 'desc' ) {
			$arr = array_reverse ( $out_terms );
		}
		$res = implode( $atts['separator'], $arr );
	}
	return $res;
});

2) Use above shortcode, like this:

 [my-post-taxonomy type="category" separator="  |  " order="asc"]

More help:
hidden link

#1619999

HI, Thank you very much for your help and your example. But... this short code would be used for many «type» and two types of separators. How would I change the function to be more flexible? I'm not confident with my programmation skills. Thank you again !

#1620599

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

You don't need to change the PHP function, just need to change the shortcode, and setup the attributes "type", "separators", "order", for example:
[my-post-taxonomy type="lieu" separator=" | " order="asc"]
[my-post-taxonomy type="lieu" separator=", " order="desc"]
...