Support

Account

Forum Replies Created

  • Well, there are pages on which we will display all the news for a project. But on other pages, we want to display only the latest three.

    But I agree, since the filter in question isn’t working the way i thought, what you proposed is probably the best way to go, yes. Thanks!

  • Hi John,

    ok, thanks for the information!

    Although it is bad news, as in our use case, this means in some cases loading quite a lot of data. Filtering it afterwards with PHP just to get 3 rows is of course possible, but not very elegant and also a performance issue.
    Especially if you consider that we would have multiple filters, like post_status, date, etc., loading all data vs loading only the required data really makes a difference to the page speed.
    Therefore, a way to filter the frontend query would be a highly appreciated future feature 😉

  • Hi John, thanks for the quick reply!
    So, we have a relationship field with the name news and the following query filter:

    add_filter('acf/fields/relationship/query/name=news', 'my_acf_fields_relationship_query', 10, 3);
    function my_acf_fields_relationship_query( $args, $field, $post_id ) {
        $args['posts_per_page'] = 3;
        return $args;
    }

    In the backend mask, this actually works and limits the result in the selector to 3 results.
    We would expect the filter to behave the same way in the frontend, limiting the result of a call to get_field(‘news’,$post_id) in a template to 3 results.
    But here the filter doesn’t seem to get applied.

  • We have the same problem. The filter does not seem to have any effect. Can you help us out here?

Viewing 4 posts - 1 through 4 (of 4 total)