Skip to content

Instantly share code, notes, and snippets.

@KittenCodes
Last active January 22, 2022 20:18
Show Gist options
  • Save KittenCodes/6a398bb432633f309559db7777e757cf to your computer and use it in GitHub Desktop.
Save KittenCodes/6a398bb432633f309559db7777e757cf to your computer and use it in GitHub Desktop.
Formation PRH Event Condition
<?php
function my_check_published_posts($type) {
$post_id = get_the_ID();
$acf_relationship_field = get_field('associations_formations_enseignants_et_evenements', $post_id);
if (empty($acf_relationship_field)) {
return "false";
}
// Build the query
$args = array(
'post__in' => $acf_relationship_field,
'post_type' => $type,
'post_status' => 'publish'
);
$query = new WP_Query( $args );
$posts = $query->posts;
if ($posts) {
return "true";
} else {
return "false";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment