Can’t add custom post type archive page to menu

Question

I cannot add this custom post type archive page to any menu from the admin. Adding via the front end customizer works fine. Viewing the archive page on the front end also works fine.

My custom post type is defined with the following code:

function events_cpt() {
$labels = array(
    'name'                  => _x( 'Award Events', 'Post Type General Name', 'text_domain' ),
    'singular_name'         => _x( 'Award Event', 'Post Type Singular Name', 'text_domain' ),
    'menu_name'             => __( 'Award Events', 'text_domain' ),
    'name_admin_bar'        => __( 'Event', 'text_domain' ),
    'archives'              => __( 'Event Archives', 'text_domain' ),
    'attributes'            => __( 'Event Attributes', 'text_domain' ),
    'parent_item_colon'     => __( 'Parent Event:', 'text_domain' ),
    'all_items'             => __( 'All Events', 'text_domain' ),
    'add_new_item'          => __( 'Add New Event', 'text_domain' ),
    'add_new'               => __( 'Add New', 'text_domain' ),
    'new_item'              => __( 'New Event', 'text_domain' ),
    'edit_item'             => __( 'Edit Event', 'text_domain' ),
    'update_item'           => __( 'Update Event', 'text_domain' ),
    'view_item'             => __( 'View Event', 'text_domain' ),
    'view_items'            => __( 'View Events', 'text_domain' ),
    'search_items'          => __( 'Search Event', 'text_domain' ),
    'not_found'             => __( 'Not found', 'text_domain' ),
    'not_found_in_trash'    => __( 'Not found in Trash', 'text_domain' ),
    'featured_image'        => __( 'Featured Image', 'text_domain' ),
    'set_featured_image'    => __( 'Set featured image', 'text_domain' ),
    'remove_featured_image' => __( 'Remove featured image', 'text_domain' ),
    'use_featured_image'    => __( 'Use as featured image', 'text_domain' ),
    'insert_into_item'      => __( 'Insert into Event', 'text_domain' ),
    'uploaded_to_this_item' => __( 'Uploaded to this Event', 'text_domain' ),
    'items_list'            => __( 'Events list', 'text_domain' ),
    'items_list_navigation' => __( 'Events list navigation', 'text_domain' ),
    'filter_items_list'     => __( 'Filter Events list', 'text_domain' ),
);
$rewrite = array(
    'slug'                  => 'event',
    'with_front'            => true,
    'pages'                 => true,
    'feeds'                 => true,
);
$args = array(
    'label'                 => __( 'Event', 'text_domain' ),
    'description'           => __( 'A place to add/edit events', 'text_domain' ),
    'labels'                => $labels,
    'supports'              => array( 'title', 'editor', 'thumbnail', 'excerpt', 'page-attributes' ),
    'taxonomy'              => array('event-category'),
    'hierarchical'          => true,
    'public'                => true,
    'show_ui'               => true,
    'show_in_menu'          => true,
    'menu_position'         => 20,
    'menu_icon'             => 'dashicons-awards',
    'show_in_admin_bar'     => true,
    'show_in_nav_menus'     => true,
    'can_export'            => true,
    'has_archive'           => 'award-events',
    'exclude_from_search'   => false,
    'publicly_queryable'    => true,
    'rewrite'               => $rewrite,
    'capability_type'       => 'post',
    'show_in_rest'          => true,
);
register_post_type( 'events', $args );
}
add_action( 'init', 'events_cpt', 0 );

When I try to add the archive page to a menu from the Admin > Appearance > Menus it does not add. The icon next to “Add to Menu” just spins.

spinning after hitting add to menu

The js console is showing error:

Failed to load resource: the server responded with a status of 500 ()

on admin-ajax.php

Adding any other archive page or any other menu item seems to work fine for both the front end customizer or through Admin > Appearance > Menus.

Any ideas on how to solve the issue would be greatly appreciated.

0
Tommizzy 1 month 2023-04-24T10:43:10-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse