Home › Forums › ACF PRO › Exclude Relationship Field Posts from Custom Query › Reply To: Exclude Relationship Field Posts from Custom Query
// this array_merge will fail if any of the fields do not have selections
// this is quick to show an example
// each field should be gotten separately
// checked and merged if it is not empty
$selected_posts = array_merge(
get_field('selecciona_post_hero', false, false),
get_field('selecciona_posts_destacados_1', false, false),
get_field('selecciona_posts_destacados_2', false, false),
get_field('selecciona_posts_destacados_3', false, false));
$query_args = array(
'post_type' => 'post',
'posts_per_page' => 2,
'paged' => $paged,
'post__not_in' => $selected_posts
);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.