Print ACF Custom Fields In Genesis

The code in this tutorial shows you how to print custom field content on single posts and/or the Genesis blog page template. You can use any Genesis hooks to control the position custom field content is displayed.

This tutorial is based on this question from a new member :

Hi there, I just became a member and have a question that i can’t find an answer to.

The question is: I want to add custom fields using Advanced Custom Fields, which would appear on each blog post (and some of the fields would also appear on the Blog listing page itself). Can you help with where I put the code, please, as there doesn’t seem to be a single post php (or archive php) page in the theme’s code. I know how to insert the correct ACF code…i just don’t know where to put it. Thank you

The code enables you to print both text and images added using ACF’s image field.

The code also works if the ACF plugin becomes deactivated as it uses WordPress functions not ACF functions to output the value for different custom field types.

Here’s the code for logged in members:


Comments

8 responses to “Print ACF Custom Fields In Genesis”

  1. Scott Fichter Avatar
    Scott Fichter

    Thanks for the update man. It’s 12:40am on a Sunday. I’m burnt. I’ll tear into it tomorrow. I’ll get back to you. Your site rocks man.

  2. Scott Fichter Avatar
    Scott Fichter

    Hey Brad,

    How are you holding up man? Per this post at the site. https://wpsites.net/web-design/print-acf-custom-fields-in-genesis/. I’ve been able to use your code examples to create a custom template file. It prints my ACF fields perfectly. I understand it and it works. It appears that this code is for the actual full post (not the blog roll). What PHP is used to format layout for the linkable blog roll list? This is where I’m fuzzy. I don’t understand how approch the solution. Can you point me in the right direction?

    Thanks very much for your awesome website. The service is fantastic.

    PS. Did you kill your Facebook account? The support link does not work.

    1. Hello Scott. Thanks for letting me know the code needs testing. Do you want to print ACF value in the excerpt on the blog page template archive? I just updated the code for the image custom field.

      This is what i get when i use WordPress custom fields to print the CF value in the bog page template entry :

      The code for adding text and images using ACF would be different. Did you want to use ACF or WP custom fields?

      1. Scott Fichter Avatar
        Scott Fichter

        My plan was to use ACF. I need to wrap my brain around how to edit the blog roll layout code so when a user clicks a summary in the blog roll it goes to full post view. Maybe I’m missing something, do all three of your code examples above accomplish this?

        1. What do you mean by blog roll? Which template are you referring to.

          Do you mean the home page archive or the blog page template archive?

          Can you link to the live archive page in question?

        2. Scott Fichter Avatar
          Scott Fichter

          I should better explain myself.

          1) I’m using a custom template PHP file so all I have to do is create the page, select the template and the layout works.
          2) Data is submitted via ACF fields
          3) The custom post type has been built by the Custom Post Type UI plugin.
          3) I’m looking to modify layout for both the blog roll and what is seen when the user clicks one of the summaries on the blog roll. I’m primarily concerned about the blog roll layout and making sure it’s linkable to the full post.

          Correct me if I’m wrong but the code above modifies the post showing the full (clicked at the blog roll) content. How to I get the scrip to show a blog roll summary that’s linkable to the full post. I hope this makes sense.

          1. I would ask the plugin dev if he has a template which overrides the plugin template in the plugin folder or maybe you can use a Genesis Template.

            Otherwise, is there any reason you need to use this plugin? How many CPT’s do you have to generate?

            You can use this code and templates if you only have 1 or 2 CPT’s.

            I would try and avoid front end reliance on plugins.

          2. What do you mean by a blog roll? Every archive lists posts. Is it the front page, home page, blog page template or another archive page type?

            Its very easy to display excerpts with the title, featured image and a content limit on archive pages which then link to single posts for each entry.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.