Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frederikrosendahlkaa/2ad88c625db4ea1582f29af2dfc288f7 to your computer and use it in GitHub Desktop.
Save frederikrosendahlkaa/2ad88c625db4ea1582f29af2dfc288f7 to your computer and use it in GitHub Desktop.
ACF-VC Integrator - Relationship field hide unpublished/private posts
<?php
add_filter('acfvc_relationship','acfvc_relationship_hide_unpublished_posts',10,3);
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