0

I'd like to display advanced custom fields on my archive page only but the following code keeps giving me an error:

<?php
    do_action( 'editorial_post_categories' );
    if ( is_single() ) {
        // do something or nothing
    } else {
        <?php the_field('acf_123'); ?>
    }
?>

The advanced custom field I like to display is "acf_123"

jrbedard
  • 3,662
  • 5
  • 30
  • 34

1 Answers1

0

Looks like you're nesting <?php tags. You've opened one at the top, so you don't need to open them again. Try:

<?php
    do_action( 'editorial_post_categories' );
    if ( is_single() ) {
        // do something or nothing
    } else {
        the_field('acf_123');
    }
?>

That is, remove the <?php and ?> around the_field() call.

Hobo
  • 7,536
  • 5
  • 40
  • 50