Thanks for the quick reply. Yes, I think the tags were automatically corrected, sorry for that. For better understanding I add all my tested loop tags in correct formatting at the end of this post.
Your solution as described in the other thread doesn’t work in this case, unfortunately, because I don’t have a meta field that I could use for sorting. The sorting should be exclusively from the order in which the posts were set in the ACF-Relationship field, but instead of ASC order in DESC order.
If that is not possible, maybe there is a workaround to reverse the order of the post IDs before I set the final variable for the loop? Possibly using list or format tags? I have not used them a lot, so I am not quite sure if such a task could be achieved with these tags.
Here are the tested loop tags with further comments on each of them
My first approach was to use the acf relationship loop as described in the documentation:
<Loop acf_relationship=my_acf_relationship_field_name>
<Field title />
</Loop>
This loop did not work at all - no posts were output as if the loop was empty. I had to rewrite it so that I store the post IDs from the relationship field as a variable and then feed those post IDs into a normal loop tag, like this:
<Set name=acf_relationship_post_ids>
<Field my_acf_relationship_field_name/>
</Set>
<Loop type=my_cpt id="{Get acf_relationship_post_ids}">
<Field title />
</Loop>
This loop correctly outputs the posts selected in the ACF relationship field. Without defining a parameter for the order within the loop tag, all posts are automatically displayed in ascending order according to their respective order in the ACF relationship field. However, it is not possible to display the posts in descending order.
For example the following loop tag still shows all posts in ascending order:
<Loop type=my_cpt id="{Get acf_relationship_post_ids}" order=desc>
To solve the sorting problem I tried to set orderby=post__in
and order=desc
, but without success:
<Loop type=my_cpt id="{Get acf_relationship_post_ids}" orderby=post__in order=desc>