Home › Forums › Front-end Issues › Relationships to un-published content › Reply To: Relationships to un-published content
Terrific! Thank you!
For anyone who may stumble on this thread… if you don’t require at least one selection to be made in your relationship fields then you may end up with a bunch of PHP warnings as it tries to check what are essentially null values. Just wrap this code in a conditional to make sure a value exists before looping through the items, like so…
if ($value) {
foreach($value as $key => $id){
if( get_post_status( $id ) == 'publish' ){
$returned_value[] = $id;
}
}
}
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.