Support

Account

Home Forums ACF PRO ACF Fields Don't Appear in Archive Template Reply To: ACF Fields Don't Appear in Archive Template

  • There’s several ways to add ACF content to CPT archives depending on whether you want to include content from single CPT pages or you only want to display the ACF content on the archive page.

    1. You can use code like this directly in your CPT archive template file

    add_action( 'genesis_entry_content', 'function_name', 12 );
    function function_name() {
        $value = get_post_meta( get_the_ID(), 'key', true );
        
        if ( ! empty( $value ) ) {
        
        echo '<div class="your-class">'. $value .'</div>';
        
        }
    }

    Or in your functions file with a conditional tag.

    2. You can also use code to create a custom CPT archive template

    There are other methods as well.

    P.S Don’t forget to include a check for the ACF class

    if ( ! class_exists( 'acf' ) ) 
        return;