Support

Account

Home Forums Add-ons Options Page Using acf/fields/post_object/query filter on options page Reply To: Using acf/fields/post_object/query filter on options page

  • Thanks to the support team, I got this to work. You don’t need to reference $post_id at all. Here’s my code:

    add_filter('acf/fields/post_object/query', 'prefix_only_published_posts', 10, 3);
    /**
     * Display only published posts
     */
    function prefix_only_published_posts( $args, $field, $post_id ) {
    	
    	$args['post_status'] = 'publish';
    	$args['orderby'] = 'date';
    	$args['order'] = 'DESC';
    		
    	return $args;
    }