Support

Account

Forum Replies Created

  • One more time, thank you a lot. At least i know what i can’t do. Now I will try to copy the post title to a meta value.

  • Hi John, first thank you a lot for replay, this is very important to me.
    Well, this is custom post type, and I don’t have that field named ‘post_title’, I used WP post_title(default title). So, how i can implement search based on title in same code?

  • EDIT:
    Code I posted is bad, this is my code:

    function custom_acf_post_object_query( $args, $field, $post_id ) {
        // Get the search text
        $the_search = $args['s'];
    
        // Remove it so ACF won't search the posts based on title
        unset($args['s']);
    
        // Search based on custom fields only
        $meta_query_args = array(
            'relation' => 'AND', 
            array(
                'relation' => 'OR', 
                array(
                    'key'     => 'post_title', 
                    'value'   => $the_search,
                    'compare' => 'LIKE'
                ),
                array(
                    'key'     => 'content_shop_api_key',
                    'value'   => $the_search,
                    'compare' => 'LIKE'
                )
                
            ),
           array(
                    'key'     => 'free_content_check',
                    'compare' => 'LIKE',
                    'value'   => $the_search,
                )
        );
    
        $args['meta_query'] = $meta_query_args;
    
        return $args;
    }
    
    add_filter('acf/fields/post_object/query/name=assign_user_product', 'custom_acf_post_object_query', 10, 3);
Viewing 3 posts - 1 through 3 (of 3 total)