Restricting Fields in wp_get_recent_posts

Looking at the function, there is no way to successfully restrict the fields in wp_get_recent_posts, is the only solution to write a WP_Query from scratch for a plugin?

Im requesting a lot of records as you can tell from code. I added the limit because I was running out of memory.

Trying to reduce the footprint of the data returned by restricting field queried and returned.

$args = array(
‘numberposts’ => 1000,
‘offset’ => 0,
‘post_type’ => ‘post’,
‘orderby’ => ‘post_date’,//’post_date’,
‘order’ => ‘DESC’,
‘date_query’ => array(
‘after’ => strtotime(‘2 years ago’)
‘include’ => ”,
‘exclude’ => ”,
‘meta_key’ => ”,
‘meta_value’ => ”,
‘fields’ => array(‘post_title’, ‘ID’, ‘post_author’),
‘post_status’ => $rollcall_basicstats_post_status

$recent_posts = wp_get_recent_posts( $args, ARRAY_A );

Read more here:: Restricting Fields in wp_get_recent_posts

Leave a Reply

Your email address will not be published. Required fields are marked *