1

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.

Error log is giving the following message:

[24-Apr-2023 17:31:02 UTC] PHP Warning: Undefined property: WP_Post_Type::$term_id in /wordpress-versions/6.1.1/wp-includes/nav-menu.php on line 966 [24-Apr-2023 17:31:02 UTC] PHP Warning: Undefined property: WP_Post_Type::$term_id in /wordpress-versions/6.1.1/wp-includes/nav-menu.php on line 969 [24-Apr-2023 17:31:02 UTC] PHP Warning: Undefined property: WP_Post_Type::$parent in /wordpress-versions/6.1.1/wp-includes/nav-menu.php on line 970 [24-Apr-2023 17:31:02 UTC] PHP Warning: Attempt to read property "name" on bool in /wordpress-versions/6.1.1/wp-includes/nav-menu.php on line 974 [24-Apr-2023 17:31:02 UTC] PHP Warning: Attempt to read property "labels" on bool in /wordpress-versions/6.1.1/wp-includes/nav-menu.php on line 975 [24-Apr-2023 17:31:02 UTC] PHP Warning: Attempt to read property "singular_name" on null in /wordpress-versions/6.1.1/wp-includes/nav-menu.php on line 975 [24-Apr-2023 17:31:02 UTC] PHP Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in /wordpress-versions/6.1.1/wp-includes/class-wp-rewrite.php:647 Stack trace: #0 /wordpress-versions/6.1.1/wp-includes/taxonomy.php(4573): WP_Rewrite->get_extra_permastruct(Array) #1 /wordpress-versions/6.1.1/wp-includes/nav-menu.php(978): get_term_link(Object(WP_Post_Type), Array) #2 [internal function]: wp_setup_nav_menu_item(Object(WP_Post_Type)) #3 /wordpress-versions/6.1.1/wp-admin/includes/ajax-actions.php(1532): array_map('wp_setup_nav_me...', Array) #4 /wordpress-versions/6.1.1/wp-includes/class-wp-hook.php(308): wp_ajax_add_menu_item('') #5 /wordpress-versions/6.1.1/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) #6 /wordpress-versions/6.1.1/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #7 /wordpress-versions/6.1.1/wp-admin/admin-ajax.php(188): do_action('wp_ajax_add-men...') #8 {main} thrown in /wordpress-versions/6.1.1/wp-includes/class-wp-rewrite.php on line 647

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

1
  • 1
    did you check your PHP error log? a 500 is a generic server side error, look at the PHP error message to find out what the real error message is
    – Tom J Nowell
    Commented Apr 24, 2023 at 17:14

1 Answer 1

0

Please look at your file permission and ensure everything is up to date like the plugin, PHP version, WordPress-compatible version and file upload limit.

Your Answer

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

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