• Resolved creative_lounge

    (@creative_lounge)


    I have this strange behaviour happening with multiple custom post types. I am sure the code for each CPT is correct, as I am able to get them to display on the admin menu, but I can only get 4 to display at any one time. There is always one missing from the menu. I am wondering if this has anything to do with the menu position !? I just can’t figure this one out.

    Here is the code I am implementing, any assistance would be greatly appreciated. Thanks

    <?php
    add_action ('init','custom_post_types');
    
    function custom_post_types() {
    
            $labels = array(
                'name'              => _x( 'Slides', 'post type general name' ),
                'singular_name'     => _x( 'Slide', 'post type singular name' ),
                'add_new'           => __( 'Add New Slide' ),
                'add_new_item'      => __( 'Add New Slide' ),
                'edit_item'         => __( 'Edit Slide' ),
                'new_item'          => __( 'New Slide' ),
                'view_item'         => __( 'View Slide' ),
                'search_items'      => __( 'Search Slides' ),
                'not_found'         => __( 'Slide' ),
                'not_found_in_trash'=> __( 'Slide' ),
                'parent_item_colon' => __( 'Slide' ),
                'menu_name'         => __( 'Slides' )
            );
            $taxonomies = array();
            $supports = array('title','thumbnail');
            $post_type_args = array(
                'labels'            => $labels,
                'singular_label'    => __('Slide'),
                'public'            => true,
                'show_ui'           => true,
                'publicly_queryable'=> true,
                'query_var'         => true,
                'capability_type'   => 'post',
                'has_archive'       => false,
                'hierarchical'      => false,
                'rewrite'           => array( 'slug' => 'slides', 'with_front' => false ),
                'supports'          => $supports,
                'menu_position'     => 25, // Where it is in the menu. Change to 6 and it's below posts. 11 and it's below media, etc.
                'menu_icon'         => get_template_directory_uri() . '/inc/slider/images/icon.png',
                'taxonomies'        => $taxonomies
            );
            register_post_type('slides',$post_type_args);
    
    		register_post_type('homepage-highlight',
    			array (
    				'labels' => array(
    					'name' => __('Homepage Highlight'),
    					'singular_name' => __('Homepage Highlight'),
    					'add_new' => __('Add New', 'Homepage Highlight'),
    		    		'add_new_item' => __('Add New Homepage Highlight'),
    		    		'edit_item' => __('Edit Homepage Highlight'),
    		    		'new_item' => __('New Homepage Highlight'),
    		    		'all_items' => __('All HP Highlights'),
    		    		'view_item' => __('View Homepage Highlights'),
    		    		'search_items' => __('Search Homepage Highlights'),
    		    		'not_found' =>  __('No Homepage Highlights found'),
    		    		'not_found_in_trash' => __('No Homepage Highlights found in Trash'),
    		    		'menu_name' => __('HP Highlights')
    				),
    				'public' => true,
    				'has_archive' => true,
    				'show_ui' => true,
    				'show_in_nav_menus' => true,
    				'menu_position' => 26,
    				'supports' => array('title','excerpt','thumbnail','custom-fields')
    			)
    		);
    
    		register_post_type('specials',
    			array (
    				'labels' => array(
    					'name' => __('Specials'),
    					'singular_name' => __('Special'),
    					'add_new' => __('Add New', 'special'),
    		    		'add_new_item' => __('Add New Special'),
    		    		'edit_item' => __('Edit Special'),
    		    		'new_item' => __('New Special'),
    		    		'all_items' => __('All Specials'),
    		    		'view_item' => __('View Special'),
    		    		'search_items' => __('Search Specials'),
    		    		'not_found' =>  __('No specials found'),
    		    		'not_found_in_trash' => __('No specials found in Trash'),
    		    		'menu_name' => __('Specials')
    				),
    				'public' => true,
    				'has_archive' => true,
    				'show_ui' => true,
    				'show_in_menu' => true,
    				'menu_position' => 27
    			)
    		);
    
    		register_post_type('testimonials',
    			array (
    				'labels' => array(
    					'name' => __('Testimonials'),
    					'singular_name' => __('Testimonial'),
    					'add_new' => __('Add New', 'testimonial'),
    		    		'add_new_item' => __('Add New Testimonial'),
    		    		'edit_item' => __('Edit Testimonial'),
    		    		'new_item' => __('New Testimonial'),
    		    		'all_items' => __('All Testimonials'),
    		    		'view_item' => __('View Testimonials'),
    		    		'search_items' => __('Search Testimonials'),
    		    		'not_found' =>  __('No Testimonials found'),
    		    		'not_found_in_trash' => __('No Testimonials found in Trash'),
    		    		'menu_name' => __('Testimonials')
    				),
    				'public' => true,
    				'has_archive' => true,
    				'show_ui' => true,
    				'show_in_menu' => true,
    				'menu_position' => 28
    			)
    		);
    
    		register_post_type('events',
    			array (
    				'labels' => array(
    					'name' => __('Events'),
    					'singular_name' => __('Event'),
    					'add_new' => __('Add New', 'event'),
    		    		'add_new_item' => __('Add New Event'),
    		    		'edit_item' => __('Edit Event'),
    		    		'new_item' => __('New Event'),
    		    		'all_items' => __('All Events'),
    		    		'view_item' => __('View Event'),
    		    		'search_items' => __('Search Events'),
    		    		'not_found' =>  __('No events found'),
    		    		'not_found_in_trash' => __('No events found in Trash'),
    		    		'menu_name' => __('Events')
    				),
    				'public' => true,
    				'has_archive' => true,
    				'show_in_menu' => true,
    				'show_ui' => true,
    				'menu_position' => 29
    			)
    		);
    }
    ?>

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • nickkos

    (@nickkos)

    Remove all menu position code.

    Thread Starter creative_lounge

    (@creative_lounge)

    Thanks Nickkos. That did the trick and saved me many painful hours.

    nickkos

    (@nickkos)

    the reason that happens…is a plugin or outside source is competing for that position.

    Thread Starter creative_lounge

    (@creative_lounge)

    I was suspecting it was menu position issue, but didn’t realise that a conflict over menu position could exist. I just though they would just fall under each other !? Thanks for your explanation. It makes a lot more sense now.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Multiple Custom Post Types one not displaying.’ is closed to new replies.