Home › Forums › General Issues › Control Display of Custom Field › Reply To: Control Display of Custom Field
Hi @toad78
Please keep in mind that you are not supposed to list the post IDs you want to exclude in the get_field()
function. You should use the post ID where the post object field is assigned (1368 in your last code). Also, please don’t forget to create the excluded_pages_field post object field in your widget field group too.
So, after you set the pages you want to exclude, you should be able to do it like this:
<?php
$excluded = get_field('excluded_pages_field', 1368, false);
global $post;
if( $excluded && !in_array($post->ID, $excluded) ){
$eventcontent = get_field('event_content', 1368);
$moredetails = get_field('more_details', 1368);
$eventimage = get_field('event_image', 1368);
if(!empty($eventcontent) ): ?>
I hope this makes sense 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.