Views with relationships: order by date

Support MB Views Views with relationships: order by date

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #39405
    Sebastian KlingelSebastian Klingel
    Participant

    Hello,

    newbie question:

    I have a Meta Box View, that shows all posts, that have a relationship with the current post. This works so far. Now I would like to order the posts by date (post date). I don't understand how they are ordered by default.

    My view looks like this:

    {% set args = { post_type: 'post', nopaging: true, order: 'DESC', orderby: 'date', relationship: { id: 'superrelationship', from: post.ID } } %}
    {% set posts = mb.get_posts( args ) %}
    {% for post in relationships.superrelationship.from %}
    	<h3><a href="{{ post.url }}">{{ post.title }}</a></h3>
    	<p>Testname Feld 123: {{ post.name_test }}</p>
    	<p>{{ post.date | date( 'Y-m-d H:i' ) }}</p>
    {% endfor %}

    If I change 'ASC' or 'DESC' nothing changes. Do I miss something?

    thanks a lot!

    #39424
    PeterPeter
    Moderator

    Hello,

    Changing the order 'DESC' to 'ASC' will change the sorting posts and the argument looks working correctly. It could be a caching issue if you do not see the changes.

    Please read more the WP query parameters here https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.