Support

Account

Home Forums General Issues Post Object search for post/pages

Solving

Post Object search for post/pages

  • Hi,

    i use a Post Object Field for selecting pages (for showing related posts on the website).

    The website has more than 2000 pages.

    If I enter a keyword (or start tying a keyword) in the selection field, I get a lot of results. Is it possible to limit the results so that only results with the exact keyword in the title are displayed?

    That would help me a lot!

    Another Question: Is it possible to copy the content of a selection field and paste it into another selection field?

    Thanks a lot for helping me!

    Andreas

  • I have the same issue. I don’t know if it also searches the post content maybe?

  • Whilst it may not help, you could possibly do something like:

    add_filter('acf/fields/post_object/query/key=field_5f72f88aca170', 'my_acf_fields_post_object_query', 10, 3);
    function my_acf_fields_post_object_query( $args, $field, $post_id ) {
    
        $args['post_status'] = 'publish';
    
        return $args;
    }

    This would only show published posts.

    As you can see from the docs, it uses WP_Query

    So unless you can amend how that works to a more exact search, I don’t think it would be possible.

  • Thanks Jarvis.
    I see that to do this, one would have to filter the search query and it becomes quite harry. https://wordpress.stackexchange.com/questions/11822/how-to-limit-search-to-post-titles

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

You must be logged in to reply to this topic.