I am currently creating a WordPress theme and stumbled across an issue I don't fully understand. I display my nav menu on the position mega_menu, using:
wp_nav_menu(array('theme_location' => 'mega_menu'));
And this works on all normal posts and pages. However, when I am on the archive page of my custom post type menschen the menu does not show up. var_dumping the nav menu on the position of mega_menu does return a WP_Term object, but getting the items returns an empty array. I don't understand this strange behaviour and hope somebody can help me.
I try to display the menu in the header.php file and call get_header() on the archive page as well.
Here's the registration of my custom post type:
function thg_custom_post_type()
{
register_post_type(
'menschen',
array(
'labels' => array(
'name' => __('Menschen'),
'singular_name' => __('Mensch'),
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'taxonomies' => array( 'category' ),
'menu_icon' => 'dashicons-businesswoman',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'custom-fields' ),
'rewrite' => array( 'slug' => 'menschen' ),
)
);
}
add_action('init', 'thg_custom_post_type');