## How to combine two get_posts into one string for pre_get_posts?

Question

I have two get_posts that each are used to exclude 1 post from each category. Both output a post_ID that are used to exclude a post in the main query in pre_get_posts and I’m having difficultly trying to combine both of those strings into one. I’ve tried array_combine and array_merge with no results.

My code:

if ( $query->is_home() &&$query->is_main_query() ) {
$exclude = get_posts( array( 'category_name' => 'podcast-control-daily,video', 'posts_per_page' => 1, 'fields' => 'ids' ) );$exclude2 = get_posts( array( 'category_name' => 'video', 'posts_per_page' => 1, 'fields' => 'ids' ) );
$query->set( 'post__not_in',$exclude,$exclude2 );$query->set('posts_per_page', 15);
}

0
8 months 2020-12-06T01:10:41-05:00 0 Answers 8 views 0