Custom Fields
Re-Envisioned
Support MB Relationships Relationships – change order of posts returned by shortcode

  • Creator
    Topic
  • #12832
    Max Elman
    Participant

    I’m using this shortcode – how can I display the returned posts alphabetically?

    [mb_relationships id="therapists_to_modalities" direction="to" mode="ul"]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Author
    Replies
  • #12843
    Anh Tran
    Keymaster

    Hi Max,

    Currently, it’s not supported in the shortcode (although it’s available via PHP when you use WP_Query and set the orderby parameter). We’ll add order parameter to the shortcode soon.

    #12845
    Max Elman
    Participant

    Ok thanks. Can you provide an example in PHP? I didn’t see it when looking.

    #12847
    Farheen
    Participant

    Hello Max

    To sort in alphabetical order please check the link Display in alphabetical order

    #12856
    Max Elman
    Participant

    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)

    Link: https://www.massagetherapypaloalto.com/modalities/clinical-deep-tissue-massage/

    #12859
    Anh Tran
    Keymaster

    Hi Max, the order and orderby should be outside of relationship param, 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,
    ) );
    #12860
    Max Elman
    Participant

    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:

    https://staging-massagetherapypaloalto.kinsta.cloud/modalities/clinical-deep-tissue-massage/

    Relationship code: https://cl.ly/d4dd24cd5582

    Display code: https://cl.ly/991ead53fdc7

    Thank you.

    #12897
    Max Elman
    Participant

    Hi – Hoping for a response since this is on a live site. Thank you!

    #12916
    Tu Duong
    Participant

    Hi, 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!

    #12934
    Max Elman
    Participant

    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.

    #12945
    Tu Duong
    Participant

    Hi 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.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
grid gear info copy caret-up caret-down trash