Relationships - change order of posts returned by shortcode
Support › MB Relationships › Relationships - change order of posts returned by shortcode
- This topic has 10 replies, 4 voices, and was last updated 6 years, 11 months ago by
Tu Duong.
-
AuthorPosts
-
December 30, 2018 at 9:47 AM #12832
Max Elman
ParticipantI'm using this shortcode - how can I display the returned posts alphabetically?
[mb_relationships id="therapists_to_modalities" direction="to" mode="ul"]January 2, 2019 at 9:49 AM #12843Anh Tran
KeymasterHi Max,
Currently, it's not supported in the shortcode (although it's available via PHP when you use WP_Query and set the
orderbyparameter). We'll add order parameter to the shortcode soon.January 2, 2019 at 10:23 AM #12845Max Elman
ParticipantOk thanks. Can you provide an example in PHP? I didn't see it when looking.
January 2, 2019 at 1:12 PM #12847Farheen
ParticipantHello Max
To sort in alphabetical order please check the link Display in alphabetical order
January 3, 2019 at 2:46 AM #12856Max Elman
ParticipantThanks. I had meant an example of using WP_Query and relationships, but I found it on your site. I'm using this updated code, however posts are still not alphabetized - can you explain why not?
Code: https://cl.ly/76ea47f4f474 (This forum was encoding characters wrong)
Link: https://www.massagetherapypaloalto.com/modalities/clinical-deep-tissue-massage/
January 3, 2019 at 9:21 AM #12859Anh Tran
KeymasterHi Max, the
orderandorderbyshould be outside ofrelationshipparam, as they're arguments forWP_Query. Please try:$connected = new WP_Query( array( 'relationship' => array( 'id' => 'therapists_to_modalities', 'to' => get_the_ID(), ), 'orderby' => 'name', 'order' => 'ASC', 'nopaging' => true, ) );January 3, 2019 at 10:24 AM #12860Max Elman
ParticipantHi - Unfortunately something is still wrong. I'm using that code and the order has not changed. To rule out any other factors I disabled all other plugins and am using the 2019 theme here:
https://staging-massagetherapypaloalto.kinsta.cloud/modalities/clinical-deep-tissue-massage/
Relationship code: https://cl.ly/d4dd24cd5582
Display code: https://cl.ly/991ead53fdc7
Thank you.
January 5, 2019 at 7:22 AM #12897Max Elman
ParticipantHi - Hoping for a response since this is on a live site. Thank you!
January 7, 2019 at 2:24 PM #12916Tu Duong
ParticipantHi, Max
I checked the code you sent and found it working normally
demo check: https://www.youtube.com/watch?v=ANgWu_NEjKM&feature=youtu.be
code check : https://ghostbin.com/paste/xtz72
thank you!January 8, 2019 at 1:41 AM #12934Max Elman
ParticipantThank you - the demo appears to work fine. Could the difference be that you based that on a post / page relationship, and mine is based on two custom post types? That's the only difference that I can see.
January 8, 2019 at 3:29 PM #12945Tu Duong
ParticipantHi Max,
Yes, I have changed post_type to be able to correctly check your issuse.
But the issuseI want to say here is that your code is sent, it runs normally.
So your unscheduled error may be due to another issuse, so you can check back. -
AuthorPosts
- You must be logged in to reply to this topic.