Support

Account

Home Forums General Issues Can't get ACF fields to display on other pages

Helping

Can't get ACF fields to display on other pages

  • I have read through almost every documentation page and looked at all the code examples, watched many youtube videos and I just can’t get it to work. I used to code and am getting back into it. I understand how the logic of it all works but I just can’t get the right variables in the right spots to pull the data.

    Spects.., I have ACF and CPT UI installed. I created a post type name: discord_channels
    I made a field group called Discord Ads and inside it I made many fields. One of the field names is discord_channel_title.

    I have the location rule set to Post type is equal to discord_channels.

    I have tried using the long PHP code in a code box (I am using the Avada Theme) and the short code. But I can’t get it to pull anything. I have even followed youtube videos and tried to make a template for it to use but it didn’t work.

    Can someone please post what the code should look like if I want to pull the discord_channel_title from the discord_channels post and display it on my home page or any other page that isn’t it’s post page.

  • I can’t give you any help with Avada, I don’t know anything about it.

    With basic PHP you need to supply the post ID of the post you want to get the value from.

    the_field('discord_channel_title', $post_id);

    How or where you’d get this post ID value at the location you want to show the value is what I can’t say. Usually there is some type of loop. For example the standard WP post loop looks something like this

    
    while (have_posts()) {
      the_post();
      // $post_id is assumed to be the post ID of this post
      the_field('discord_channel_title');
    }
    

    I can’t say how you would get the post ID where you are trying to use ACF in Avada.

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

The topic ‘Can't get ACF fields to display on other pages’ is closed to new replies.