Support Forum
Hi, in the admin area I can drag and drop the order of the chosen items of the relationship. That's nice.
But how do I show that same order in the frontend?
The closest I saw in get_posts is orderby:'none', but it doesn't help.
So is there a way to show in frontend the same order as in backend?
Hello Eddy,
The order of relationship items in the front end will display the same order as in the admin area. Can you share some screenshots of the issue and the code that you use to output the relationship?
Peter, this is the code for the page.
{% set args1 = { post_type: 'repetitie-avond', posts_per_page: -1, orderby: 'date', order: 'asc' } %}
{% set posts = mb.get_posts( args1 ) %}
{% for post in posts %}
<h2><strong>{{ post.title }}</strong></h2>
<p>{{ post.content }}</p>
{% set args2 = {post_type: 'muziek', nopaging: true, orderby:'none', relationship: {id: 'muziek-op-repetitie-avond', from: post.ID}} %}
{% set muzieknummers = mb.get_posts( args2 ) %}
{% set counter = 0 %}
{% for muziek in muzieknummers %}
{% set counter = counter +1 %}
{% set post2 = mb.get_post( muziek.ID ) %}
<p><a href="{{ post2.url }}">{{ post2.post_title }}</a></p>
{% endfor %}
{% if counter == 0 %}
Er is nog geen muziek voor deze avond vastgelegd. - no music yet -
{% endif %}
<hr />
{% endfor %}
Here is a short video of all settings involved: https://drive.google.com/file/d/1Ok9HploeRIkomw7uukIa7cuikxAFH1gN/view?usp=drive_link
Regards,
Eddy
Hello,
You are using the parameter orderby:'none'
so the relation posts will be displayed with no order. Please remove it and check the issue again.
Peter,
If I do that, they are shown in descending order of title, that's not the order in the backend.
That's why I tried orderby: none, hoping that it would result in the order of the backend, but it didn't work. That's exaclty why I started this thread.
So any advise?
Please remove the order parameter from both args1 and args2 then check the issue again. If it still doesn't work, you can share your admin account by submitting this contact form https://metabox.io/contact/
I will take a look.
Peter, it didn't make a difference, so I've set up an admin account for you, and sent the login credentials as requested.
Thanks, good luck.
Peter, fyi:
I did a complete plugin conflict test with theme Twenty Four, and still the same.
Looking forward to your advise.
@EddyPiV @Peter
Still no solution for this?
I am using Oxygen and also want the related entries in the order the user drags them in the backend.
I used advanced query builder and only args are post_type, post__in and no_found_rows (true).
Solution for oxygen query builder (can't Edit):
oderby
array ---> [key -> post__in] [value -> ASC]