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;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.