Support

Account

Home Forums ACF PRO Variable not showing in Single Post page

Solving

Variable not showing in Single Post page

  • Hi,

    I have this variable that pulls in the value from get_field(‘parent_series’), this is a textbox where I can enter the name of the parent series which I then used as a parameter in my loop to find other posts with the same parent series and display them.

    This works great in the main index page using the_field(‘parent_series’) inside a custom loop, but it doesn’t show in the single post page. It case it’s conflicting with some of the scripts I have in that page, is there an alternate way to pull the data from the wordpress database? Pls show me a simple script to do this.

  • I could not see anything simpler than the_field() or get_field(). You should not bypass that point without cleaning your script.

    You should test (in the top of the script or the loop) if the related post in the single post page has the ‘parent_series’ set:

    <?php
    die(get_field('parent_series');
    ?>

    Or maybe your problem is simply related with a misunderstanding of the WordPress loop which could easily leads to strange behaviour like the one your are talking about.

  • Hi @GeekyPinoy

    It is possible that where you have placed the get_field code, WP has not yet setup the correct global $post data.

    You can test this by using the function get_the_ID(). Please use this function to test if the returned ID is indeed the post you are viewing

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

The topic ‘Variable not showing in Single Post page’ is closed to new replies.