Support

Account

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 🙂