2

I have a common design pattern I'm not entirely sure how to best execute in WordPress. The layout is a listing of post teasers (title, trimmed body, image) on an overview page. Let's say example.com is a boating safety company, and at example.com/classes there's a listing of their posts of the class type using archive.php or archive-$posttype.php

So far it's dead simple and default WordPress behaviour. But, I want to have some intro information about this type of information in general on this overview page. Furthermore, let's say I have 10 custom post types hypothetically, and each one would follow this pattern with a listing and a general introductory paragraph on the archive page.

What I don't want to do is have a page for each of these types, and a custom query done for each of them in a page template. If there were a way to associate a description, and even better custom fields, with the post type itself (not on posts of that type but the type itself) that would be the ideal scenario. Ideally I'd like to have this all wrapped into my archive.php template.

Does anybody know of a good way to pull this off?

This may or may not be helpful, but I'll be creating post types in code but using Advanced Custom Fields for the custom fields themselves.

2
  • It would really help if you could show some kind of (pseudo)code.
    – alpipego
    Commented Nov 14, 2014 at 21:38
  • U can use my plugin ACF CPT Options Pages Download here Commented Feb 26, 2016 at 11:49

1 Answer 1

1

I have to do similar things all the time. You are already using ACF, which is what I use, actually I use ACF5 Pro version now, but the same thing can be achieved using ACF4 and the Options Page add on.

What I do is create an options page for each post type and set the parent of is so it appears as part of the fly out for the post type. Then I create custom fields for the option page and one of the fields is a wysiwyg field for the content.

Each options page needs to have unique field names because ACF stores data for these fields in the wp_options table, so it means duplicating the field group and giving each field a unique name. If you are using ACF Pro, I have actually created a plugin that will actually do create the options pages through a user interface and can also do the field group duplication and updates automatically. https://github.com/Hube2/acf-options-page-adder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.