Support

Account

Home Forums Backend Issues (wp-admin) Pass the post id as reference without hard coding it

Unread

Pass the post id as reference without hard coding it

  • Hi,

    I’m newbie with ACF Pro and I was wondering how can I do what the title says?

    For example I have this code:

    <?php
    $about_post_id = 34;
    ?>
    
    <h2 class="text-center text-black">
        <?php the_field( 'dog_title', $about_post_id ); ?>
    </h2>

    How can I provide the post id without saying it’s 34 or X. I need a way to find it dynamically, is that possible? I was trying with functions like get_the_id() and so on, within the have_posts() loop without much success.

    I’m working on the front-page.php file, and this is a One page website, using CPT UI to make it editable.

    Do I have to work with another php file in order to be able to get it?

    Thanks.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.