Last active
January 22, 2022 20:18
-
-
Save KittenCodes/6a398bb432633f309559db7777e757cf to your computer and use it in GitHub Desktop.
Formation PRH Event Condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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