1

My question is one of theming best practices. I constantly running into an issue were I have to display editable content on a custom post type archive page for client work - such as an image, body of text or custom page title. I've found this post and it references the options api. I'm not looking for the easiest way, but rather the Wordpress way or maybe some insight from others.

Things I've tried in the past:

  • create custom post type archive page, use the advanced custom field plugin to create a specific options page for custom post type archives. This works, but can be confusing to the user where they have to visit a theme options page for custom post type archive "meta" data, while all other page data is maintained through a page post.
  • create a page template, write a function calling custom post type data with wp_query, then use the meta data for any other extra fields
  • use the repeater field in advanced custom fields on page template, without using a custom post type. This could work if the data list was short and didn't need pagination, but will still be cumbersome accessing meta data from a separate post.

Essentially, I just want to start the conversation on how other developers solve this issue.

2

After some offline conversations with other developers, I came to the solution of creating a settings page under any given custom post type menu. A quick way to get up and running is by using Advanced Custom Fields PRO with this handy snippet by Jared Atchison:

<?php
/**
 * Create ACF setting page under Events CPT menu
 *
 * @since 1.0.0
 */
if ( function_exists( 'acf_add_options_sub_page' ) ){
    acf_add_options_sub_page(array(
        'title'      => 'Event Settings',
        'parent'     => 'edit.php?post_type=events',
        'capability' => 'manage_options'
    ));
}
  • FYI - Options are only supported by ACF PRO – Django Reinhardt Apr 18 '16 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.