Home Forums ACF PRO Post Object variable is empty but not on edit page


Post Object variable is empty but not on edit page

  • I have an issue where I’m trying to pull in related posts from a CPT onto a post single page using the post object field, but I can’t get it to show on the front end. I’ve boiled the troubleshooting down to just testing if the variable is empty:

    <?php $relatedProject = get_field('pl_related_projects');
    	if ( ! empty( $relatedProject ) ) : ?>
    		<p>Not Empty</p>
    	<?php else : ?>
    	<?php endif; ?>

    …and it returns as “Empty”. But, in the post edit page. The field is filled out with a selected CPT.

    I’ve confirmed and reconfirmed the correct field is showing in the post edit page. I selected different CPTs, multiple CPTs and updated the post. But it still shows as an empty variable.

    Does anyone have ideas on what I am doing wrong?

    WP 5.8.1
    ACF Pro 5.10.2

  • Skip this question…I found my issue. I didn’t realize in another portion of the template there was a different WP Query. The variable was pulling from the wrong content.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.