0
votes

I need help in Advanced custom field pro plugin i want to display 3 post of credit taxonomy to the home page i had edited my field group like :

  • Field Label : home credit
  • Field Name : home_credit
  • Field Type : Post object
  • Filter by taxonomy : credit

Now, when i print the data to the homepage by writing this : - get_field('home_credit', get_the_ID()) );

i am not getting the value from the post object or how to retrieve its value please help. I had also try to debug the value by print_r but no value returning.

2

2 Answers

0
votes

if you need fetch data on taxonomy page by ACF,

<?php the_field('home_credit','credit_' . term_id); ?>
0
votes

Looks like the ID you are using to retrieve the data is not correct. You might have to check what "get_the_ID()" returns to make sure you are using the correct page ID. One solution would be to use "get_queried_object_id()" instead. Try :

$home_credit = get_field( 'home_credit', get_queried_object_id() );

Basically get_queried_object_id() will get the ID of the object queried in the current wp_query. get_the_ID() might fail if post data is not set.