• Hi. Let me start with my code first off…

    function wuss_games_post() {
    	$labels = array(
    		'name'                => _x( 'WUSS Game', 'Post Type General Name', 'text_domain' ),
    		'singular_name'       => _x( 'WUSS Game', 'Post Type Singular Name', 'text_domain' ),
    		'menu_name'           => __( 'WUSS Games', 'text_domain' ),
    		'parent_item_colon'   => __( 'Parent Game:', 'text_domain' ),
    		'all_items'           => __( 'All Games', 'text_domain' ),
    		'view_item'           => __( 'View WUSS Game', 'text_domain' ),
    		'add_new_item'        => __( 'Add New WUSS Game', 'text_domain' ),
    		'add_new'             => __( 'Add New', 'text_domain' ),
    		'edit_item'           => __( 'Edit WUSS Game', 'text_domain' ),
    		'update_item'         => __( 'Update WUSS Game', 'text_domain' ),
    		'search_items'        => __( 'Search WUSS Game', 'text_domain' ),
    		'not_found'           => __( 'Not found', 'text_domain' ),
    		'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' ),
    	);
    	$rewrite = array(
    		'slug'                => 'wuss_game',
    		'with_front'          => true,
    		'pages'               => true,
    		'feeds'               => true,
    	);
    	$args = array(
            'label'               => __( 'wuss_game', 'text_domain' ),
            'description'         => __( 'WUSS Games', 'text_domain' ),
    		'labels'              => $labels,
    		'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields'),
    		'hierarchical'        => true,
    		'public'              => true,
    		'show_ui'             => true,
            'show_in_menu'        => "wuss_framework",
    		'show_in_nav_menus'   => true,
    		'show_in_admin_bar'   => true,
    		'can_export'          => false,
    		'has_archive'         => false,
    		'exclude_from_search' => false,
    		'publicly_queryable'  => true,
    		'rewrite'             => $rewrite,
    		'capability_type'     => 'page',
    	);
    	register_post_type( 'wuss_game', $args );
    }
    
    add_action( 'init', 'wuss_games_post', 0 );

    Right, now, the problem. When I activate my plugin my top level menu is created just fine:

    if (is_multisite()) {
    	add_action( 'network_admin_menu', 'register_wuss_framework', 5 );
    }
    else {
    	add_action( 'admin_menu', 'register_wuss_framework', 5 );
    }
    
    function register_wuss_framework()
    {
    	add_menu_page("WORDPRESS UNITY SOCIAL SYSTEM", "WUSS", "manage_wuss", "wuss_framework", "show_wuss_framework",'dashicons-smiley');
    	do_action('register_subsystems',12);
    }
    

    This creates the WUSS menu as I intended. My plugin is set to only appear in the Network Admin page and there the WUSS menus displays just fine. When I use a single site install, the post type above appears as a sub-menu of the WUSS menu, as expected. When I install this on a multisite, the custom post type does not appear in the menus. Why not?

    I tried setting the plugin to show up on individual sites also and that allows me to activate the plugin on the sub-site but the menu still appears in the network dashboard without the custom post type.

    I tried moving the custom post type into the function that gets called during init and have it load before or after function has done it’s thing but still no custom post type.

    I tried manually entering the post type into the URL so I can see if I can make posts and that works just fine. Also, by tinkering with the code I posted at the top I was able to get the custom post type to appear on the site’s admin panel but that is the ONLY place where I can actually see the custom post type and edit it.

    Problem is that I do not want it editable on a site by site basis. I want to do a network activate and then have the custom post type appear underneath my custom menu on the network admin dashboard just like the main menu does. Why can I not do this?

    Am I doing something wrong or is this simply something that is not supported ?

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter Ryunosuke

    (@mybadstudios)

    Okay, well I still don’t understand why my custom post type is not appearing but I did find a hack around it. It all started when I found there is a ‘network_admin_menu’ hook.

    It appears that for normal sites the custom post types are registered during ‘init’ as the documentation expressly states “You should only do that during the init hook”, fine, but for admin menus that has no result so I have to add it manually. But here comes the catch… How do you make a menu item that goes under a specific menu and redirects to the page you want?

    Why is this an issue? Well, because the add_submenu_page function stated it wants a FUNCTION to be called when the item was clicked. Simply adding the URL there resulted in “This is not a function, you fool” errors. So I tried to make it call a function that goes to the page in question… But how do you tell php to load a new page?

    Google it and you will find 3 billion posts telling you “use header() but do so before any output is written” or people that say “if you can’t use header() because you already have content printed to the screen then you have coded your website wrong”. Do you hear that, WordPress developers? The internet is unanimous that your entire admin system is coded wrong because you can’t first SHOW people the button they can click on, oh no, the link the button goes to should open up BEFORE the user gets to click on the link. How stupid of you to not realise such a huge mistake? Fix WordPress NOW, I say….

    So after I realised that that was not going to work I started looking at other angles at which to approach this and finally found something that works to some extent. I would have preferred to be able to stay in the network admin panel while creating a new entry but (now that I think about it) it seems rather daft… of course the post will have to go into the tables of one of the websites so it makes sense that when I click on the menu item it first goes to the main website before making the post…

    So, with the exception of having to return to the network admin page to make use of all the other custom functionality I added to WordPress, this hack of mine seems to work nicely.

    if (is_multisite())
    	add_action('network_admin_menu', 'add_wuss_games_submenu');
    
    function add_wuss_games_submenu() {
    	add_submenu_page(
    		'wuss_framework',
    		'wuss_games_overview',
    		'Wuss Games',
    		'manage-wuss',
    		admin_url('/edit.php?post_type=wuss_game'), 
    		null );
    }

    As you can see, I use the URL I want to load as the menu_slug parameter. I don’t know why it works but it works perfectly… The very definition of a hack if you ask me ??

Viewing 1 replies (of 1 total)
  • The topic ‘My custom post types don’t show up in multisite admin panels’ is closed to new replies.