Home Forums Backend Issues (wp-admin) Problème with filtre acf / fields / post_object / query


Problème with filtre acf / fields / post_object / query

  • Problem: acf / fields / post_object / query
    I have a back office problem to retrieve a post list with an acf (reference) custom field.
    For now I managed to display the posts with the reference but it’s when I want to make a request that it does not work.

    I used the following filter to retrieve references instead of post names:

    function my_post_object_result ($ title, $ post, $ field, $ post_id) {
        $ reference = get_field ('reference', $ post-> ID);
        return $ reference;
    add_filter ('acf / fields / post_object / result', 'my_post_object_result', 10, 4);

    it works well, but I can not use the filter to modify the search query:

    function my_post_object_query ($ args, $ field, $ post_id) {
    add_filter ('acf / fields / post_object / query', 'my_post_object_query', 10, 3);

    How can I modify the query to get the reference rather than the name of the post?
    Here is an image of my problem:

  • Here is an example of search with the name, it works and it displays the corresponding reference

  • ACF uses the built in search filter, the same search that is used when on the admin post list page and you search for a post there. In order to do this you need to modify the way that WP search posts. Try this

  • This is the right method! thanks a lot for your help !

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

The topic ‘Problème with filtre acf / fields / post_object / query’ is closed to new replies.