Add custom field to the archive page?

Add fields to archive?

I’m using Advanced Custom Fields plugin (but it’s not relevant as I can also use native WP fields) and want to add custom field to the custom post archive page.

The problem is there is no archive page by default, where you can attach the field (though you can add it to single categories as they have presence in the admin area).

Create custom page template = no highlight in the menu

One solution would be to create the custom page template for archives. But that way you loose the ability to highlight it in the navbar while on single post/category, because this new page won’t be recognized as a parent of single.

Am I correct there is no way to add fields to archive and keep the highlight in the menu?

1
1

Using the Advanced Custom Fields plugin you can assign options pages to you custom posttype like this:

if( function_exists('acf_add_options_page') )
{
    acf_add_options_page(array(
        'page_title'    => 'YOUR_PAGE_TILE Options',
        'menu_title'    => 'YOUR_MENU_TITLE Options',
        'menu_slug'     => 'options_YOUR_SLUG',
        'capability'    => 'edit_posts',
        'parent_slug'   => 'edit.php?post_type=YOUR_CUSTOM_POSTTYPE_SLUG',
        'position'      => false,
        'icon_url'      => 'dashicons-images-alt2',
        'redirect'      => false,
    ));
}

That way you get an options page you can assign fields to later. Keep in mind that all the fields you asign to that option page are not bound to your custom posttype. They are like ‘normal” option fields but you have them in your custom posttype section in the WP Backend menu.
I think it’s necessary to use the pro version of the plugin – or have the addon installed to build option pages.

Leave a Comment