phphtmlwordpressadvanced-custom-fieldsacfpro

Text entered in ACF fields not rendering in front page(index.php) - Wordpress


Guys I am facing a issue where i have created the field entered the content in the wordpress however text in not rendering in the front page.

<span class="p_sec fw600 txt-green"><?php the_field('home_news_label')?>News</span>

there are other fields having the same issue

Screenshots for reference:-

this the field added in ACF plugin

ss for content that was added

content added

Screenshot of the frontpage i also added static content which was visible frontpage

Note: I have created this as new feild so that there is no clash of field name in any field group

I think this is a bug however i am not sure, I am trying to get the text to render in the front page with acf plugin in a wordpress site


Solution

  • Hey Guys thanks for all the comments, So I this problem occurs on the front page. I still don't know why adding the post id after the field name and echo it seems to make it work fine so I added the code

    <span class="p_sec fw600 txt-green"><?php echo get_field( 'home_label_text_news',5);?></span>
    

    <?php echo get_field("home_news_label",<id of the page/post>); ?>

    ID - you can find this in the URL of the wp-admin edit page of that particular post.

    This seems to work for me. If anyone can explain why other fields are working fine which are similar in nature to this (other sections also have labels) but not working only in this one, I have also checked the field name is unique and not repeated anywhere else.