0

I use ACF added a coustom field for category.

it works fine in archive.php , here is code:

<?php echo get_field('students_no_class', get_queried_object() );?>

but it doesn’t work in author.php , nothing show up.

in author page I need disaply coustom field value after

<?php if (have_posts()) : while (have_posts()) : the_post();?>

I also did a test:when I delete author.php, the author page will use archive.php template and the coustom field show up nothing.

1
  • can you please add screenshots of acf field, author.php code and category.php file code so can clearly understand about this Aug 30, 2021 at 8:30

1 Answer 1

0

In ACF for Authors, you need to supply the author in 'user_'.$user_id format.

Which would be this:

echo get_field( 'students_no_class', 'user_'. get_queried_object()->ID );

or this:

the_field( 'students_no_class', 'user_'. get_queried_object()->ID );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.