Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ACF-VC Integrator - Relationship field hide unpublished/private posts
function acfvc_relationship_hide_unpublished_posts ( $output, $field, $id ) {
$new_output = "<ul>";
foreach ( $field["value"] as $key => $value ) {
if ( $value->post_status == "publish" ) {
$new_output .= '<li><a href="'.get_permalink($value->ID).'" title="'.get_the_title($value->ID).'">'.get_the_title($value->ID).'</a></li>';
$new_output .= "</ul>";
return $new_output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.