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;