Support

Account

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

Solving

ACF Fields Don't Appear in Archive Template

  • Using Genesis 2.2.1 + ACF 5.3.0 + WP 4.3.1.

    I need custom fields for adding an image and stuff to a Genesis Archive Template. I’ve added support of the Genesis Archive Settings (‘genesis-cpt-archives-settings’) to the custom post taxonomy in ACF.

    I create fields in ACF, and assign them to “Page Template is Equal To Archive”.

    The Problem: when I edit the Archive settings page in WP Admin, the ACF fields are nowhere to be seen.

    Am I wrong to expect them to appear in the Genesis Archive Editing page in the first place?
    Has anyone here successfully added custom fields to the Genesis Archive template?

    As usual, I’m asking this after a good six hours searching for an answer online. So I’m beginning to wonder if it’s even possible. I feel like I’m missing some single piece of key info (such as – “oh yeah, you can’t do that with ACF” lol).

    Thanks for any light!

    Chris

  • You might be better off asking over on the Genesis community forum, I don’t think there are many Genesis users that visit here that can help you, which is likely why your question has gone unanswered for so long. I didn’t answer it sooner thinking maybe someone else would be able to help you.

    To be honest I’m not familiar with it, but usually ACF requires modification of the theme files and what I think you’re looking for is the ability to modify those theme files through the Genesis admin panels.

  • Hi John,

    Thanks for your thoughts.

    I’ve been playing around with it and haven’t come up with an idea solution yet.

    The closest I’ve gotten is this:
    https://gist.github.com/srikat/11519661

    Thanks.

  • I’ve seen similar things before, that’s basically what you need to do. Create template for the custom post type or custom taxonomy or edit the existing template for the theme for that post type or taxonomy, use the hooks for Genesis to call functions and then in those functions use the correct ACF functions to display the content you want to show.

    Using Genesis basically adds a couple of extra layers of work that’s needed to get the job done, which is one of the reasons I avoid frameworks. My view is that Genesis is fine if you don’t want to or need to do a lot of coding but as soon as you need to, well…. At any rate, me and several others here can help you with the ACF code, but figuring out where to put it will require someone that really understands the framework.

  • Yes, you need to create an archive-whatever.php file and then a custom loop with the ACF fields in it.

  • 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;
Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘ACF Fields Don't Appear in Archive Template’ is closed to new replies.