• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Display Advanced Custom Fields for Custom Post Type

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Display Advanced Custom Fields for Custom Post Type

This topic is: not resolved

Tagged: advanced custom fields, Custom Post Type, hooks

  • This topic has 2 replies, 2 voices, and was last updated 2 years, 2 months ago by jadie16.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 15, 2021 at 4:25 pm #502653
    jadie16
    Participant

    Hello,

    I am having trouble finding the right code to accomplish this (and I am still learning Genesis).

    I want to display custom fields but only on a certain post type :

    ACF field group: "family-tree" with the following fields:
    'biography', 'approximate_birth_date' and ' approximate_death_date'

    I only want to show these fields on posts that are type 'member'

    Can anyone direct me to the right code/hooks for this? I am using Infinity Pro.

    Thanks!
    Julie

    January 16, 2021 at 10:48 am #502667
    Walter Lopez
    Participant

    Hello Jadie,
    Assuming you want to display the fields inside the content, I would load the function on the genesis_entry_content hook, something like:

    add_action('genesis_entry_content', 'wpa_do_family_tree');
    function wpa_do_family_tree() {
    	// Check if we are on the "member" CPT, if not bail early.
    	if ( ! is_singular('member') ) {
    		return;
    	}
    
    	$biography  = get_field('biography');
    	$birth_date = get_field('approximate_birth_date');
    	$death_date = get_field('approximate_death_date');
    
    	// Do stuff with the data.
    }

    Website: wpallied.com | Twitter: @lopwalj

    January 16, 2021 at 9:29 pm #502675
    jadie16
    Participant

    Thanks so much Walter. Will give it a try!

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble