- December 30, 2018 at 9:47 AM #12832
I’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 #12843
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 #12845
Ok thanks. Can you provide an example in PHP? I didn’t see it when looking.January 2, 2019 at 1:12 PM #12847
To sort in alphabetical order please check the link Display in alphabetical orderJanuary 3, 2019 at 2:46 AM #12856
Thanks. 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)January 3, 2019 at 9:21 AM #12859
Hi Max, the
orderbyshould be outside of
relationshipparam, as they’re arguments for
WP_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 #12860
Hi – 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:
Relationship code: https://cl.ly/d4dd24cd5582
Display code: https://cl.ly/991ead53fdc7
Thank you.January 5, 2019 at 7:22 AM #12897
Hi – Hoping for a response since this is on a live site. Thank you!January 7, 2019 at 2:24 PM #12916
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 #12934
Thank 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 #12945
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.
You must be logged in to reply to this topic.