Support

Account

Home Forums Front-end Issues Limit relationship posts per page Reply To: Limit relationship posts per page

  • I guess it depends on what order you want the posts returned in and what 5 you want to limit it to. By default, I believe, that the order that they’re returned when getting the field is the order that they are in relationship field, although I could be wrong. I just had a look and there isn’t any way to alter the order then getting the field.

    If you return an array of ID values, no query of posts is done before they are returned when using get_field(), so there isn’t any double query happening if you’re not returning post objects.

    You are right though if you return post object and do a second query then you’re basically doing 2 queries to get almost the same thing. This is where it’s important to consider and select what is returned when setting up ACF fields for what you intend to do with it later.