Skip Navigation

[Resolved] Ordering by custom last name field

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 12 replies, has 2 voices.

Last updated by Luo Yang 1 year, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#2516505
capture.jpg

Tell us what you are trying to do?
I have a custom field in a directory for Last Name. I have the view set to order by that Last Name field in Ascending order. It kind of works. It lists members in order but on page 5 it gets to the end and then starts over with users who are not displaying earlier in the order. The people listed after the last name "Wright" from pages 5-7 should be mixed into the directory in alphabetical order by last name. Instead, they all display at the end of the directory but in alphabetical order.

Is there any documentation that you are following?
no.. just setting up a view as I normally would.

Is there a similar example that we can see?

What is the link to your site?
hidden link

#2516769

Hello,

I have tried it in a fresh WP installation + the latest version of Toolset plugins, it works fine, see below test site.
Login URL:
hidden link
1) A custom post field "last-name":
hidden link
2) A post view, order by above field ASC
hidden link

Test it in frontend:
hidden link

It works fine, is there any missing steps? can you reproduce the same problem in above test site?

#2516987

Hi Luo,

I have it set the exact same way and I am having the problem. Would the search at the top of the page throw it off? What else could be causing it to not function properly. Funny thing is if I sort by first name on the page, it works perfects.

#2519103

I have tried it in the test site, add search form + sorting control.
hidden link
But don't see the issue, can you reproduce the same problem in above test site?

#2519745

No.. I can't.. but I can on my site which is why I reached out. I have the settings identical for sorting as you do on the test site. What I am looking for is help on why it would not be working properly. I am not looking to recreate the issue on a test site with no data. I am looking for help figuring out what could be causing the issue and how to fix it!

#2519965

Since the problem only exists in your website, please try these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to WordPress default theme 2022, and test again

3) If the problem still persists, please provide database dump file(ZIP file) of your website, you can put the package files in your own google drive disk, share the link only, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#2520503

I was unable to use the Duplicator as it errors out because of file size.

#2520505

Luo, after several tried I was able to generate the files you requested using duplicator. I just can't seem to add the link in private within this conversation anymore?

#2522285

Sorry for the delay answer, private message box enabled again

#2523587

I am downloading the files, will update here if find anything

#2523675
order-by.jpg

I can reproduce the same problem in my localhost with your duplicator package, but this issue seems to be a WordPress core(which can not be fixed in Toolset side).

Toolset plugins are using WordPress built-in class WP_Query to query posts, the same issue exists in WP_Query itself, for example, you can try these:
1) Edit your theme file "functions.php", create a custom shortcode with pure WordPress functions:

add_shortcode('order-by', function(){
	$args = array(
		'post_type' => 'md-profile',
		'orderby'   => 'meta_value',
		'order'	=> 'ASC',
		'meta_key'  => 'wpcf-md-last-name',
		'nopaging'	=> true
	);
	$the_query = new WP_Query( $args );
	if ( $the_query->have_posts() ) {
		$res .= '<ul>';
		while ( $the_query->have_posts() ) {
			$the_query->the_post();
			$res .= '<li>' . get_the_title() . '-' . get_post_meta(get_the_ID(), 'wpcf-md-last-name', true) . '</li>';
		}
		$res .= '</ul>';
	} else {
		// no posts found
	}
	/* Restore original Post Data */
	wp_reset_postdata();
	return $res;
});

2) Create a new page, display above shortcode:
[order-by]

Test above page in frontend, I see same issue, see my screenshot order-by.jpg

Can you confirm it in your website too?

#2524451

HI Luo,

Yes.. I do see that is does the same in the WordPress query as it does in the directory. Any idea what would cause this to happen?

Jeff

#2526149

The problem persists with or without Toolset plugins, it should be a issue of WordPress core, you can submit a ticket to them:
https://core.trac.wordpress.org/