Support

Account

Home Forums General Issues Using Custom Post Types to Display Field Values

Solved

Using Custom Post Types to Display Field Values

  • I have a feeling that I’m just missing something here about ACF custom post types.

    This is for a congregational website, and one of the sections is about adult classes that are offered. Each adult class has specific data associated with it: start date/time, end time, recurrence, facilitator, format (in person / Zoom / hybrid), etc.

    I have ACFs in use for standard post types that have to do with events, and I have edited the code that pulls in and displays the posts based on start date/time, etc. That works just fine, and most of our posts are about specific events, although we do have some general announcements.

    I realize that I *could* just add ACFs for the adult classes to the field groups used for all posts and update the code that handles all the posts, but that seems like overkill since only a small percentage of our posts (maybe 2-3 dozen max each year out of several hundred) are related to adult classes.

    I was hoping that by creating a custom post type for adult classes, I could create a field group that would only apply to that post type, and I could then display the data in those fields when I display those custom posts. I guess I was expecting a PHP template that I’d be able to edit like I edited the template for the generic posts.

    So my question is: is there a way to use a custom post type to display the values stored in fields, or am I just out of luck?

    Thanks.

  • You have to create a template for a custom post type. Each post type in WP can have 2 custom templates “archive-$posttype.php” and “single-$posttype.php”. These are not automatically created when a post type is created.

    https://developer.wordpress.org/themes/basics/template-hierarchy/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.