Incorrect order of blog posts by first publication date

I can’t seem to query for the first 20 blog posts ordered by the first_publication_date (most recent article first). Ordering of posts is incorrect as seen in screenshot below.

  const posts = await this.$prismic.api.query(
      this.$prismic.predicates.at("document.type", "blog-post"),
      {
        orderings: "[my.blog-post.first_publication_date desc]",
        page,
        pageSize: 20,
      }
    );
    commit("GET_ARTICLES", posts);

Hi @navisteps, you’re really close. When sorting by publication date, it’s a little different than sorting by a content field because the publication dates are meta fields. Here’s the syntax you should use:

{ orderings : '[document.first_publication_date desc]' }

If you make that change, it should work as you expect :slight_smile:

For anyone else reading this thread, here is the documentation page for ordering documents with Vue.js:
https://prismic.io/docs/vuejs/query-the-api/order-your-results

2 Likes

Thanks alot levi!! Very helpful as always!!