How to Build Custom Post Type with Custom Fields on All MultiSite Blogs

I've gone ahead and built 3 MU plugins...one for my custom post type, one for the taxonomies, and one for meta boxes.

By putting the plugins in the MU folder, I can get all of these to appear correctly on the main blog and all sub-blogs. But, I'm having two problems. First, the data isn't saving right. Second, the custom field information isn't showing on the post.

Without getting into all of the code, let me first ask if I'm going about this the easiest way. I don't know of any plugins that will create a post-type with custom fields throughout a multi-site network.

There a re quite a few to create them for one blog, but not for all of them.

Any thoughts?

Thanks!

  • Mason
    • DEV MAN’s Sidekick

    Hiya Greg,

    I've found the same as you and seen similar forum threads on wordpress.org stating the same.

    I'm gonna ask Ivan to drop in here and give some feedback on the best way to do this. He recently released our CustomPress plugin which gives an interface for custom post types, taxonomies, etc.

    He may have some further insight.

    Thanks!

  • Marty Thornley
    • Site Builder, Child of Zeus

    Finally checking out CustomPress for the first time. Very cool but looking for the same thing mentioned above and it doesn't seem to do it.

    I see how other users get access to the custom post type within the blog I created it in but the other blogs do not get access to the new custom post type.

    Am I missing something or is there a way to make the custom settings appear in all the sub blogs?

  • Marty Thornley
    • Site Builder, Child of Zeus

    Nevermind that :slight_smile: Just needed to network activate. Forgot this was not an mu-plugin.

    An idea though. Is it possible to activate and / or deactivate post types per theme? I could see wanting 10 different custom post types but certain themes may only need one or two.

    We could probably just hide a menu item per theme, but I feel like that is an ugly way to do it.

  • Ivan
    • The Incredible Code Injector

    @Marty Thornley

    An idea though. Is it possible to activate and / or deactivate post types per theme? I could see wanting 10 different custom post types but certain themes may only need one or two.

    We could probably just hide a menu item per theme, but I feel like that is an ugly way to do it.

    Yes, this is interesting, I will have to think this through and will get back to you with solution/feature release patch.

  • Marty Thornley
    • Site Builder, Child of Zeus

    I found a quick solution that sort of works for this. Really just a way to hide the post type from the menu, not remove it all together.

    $post_types = array ('post_type_1','post_type_2');

    if (!defined('REMOVE_POST_TYPES')) define('REMOVE_POST_TYPES',maybe_serialize($post_types));

    if (defined('REMOVE_POST_TYPES')) {
    add_filter( 'custom_menu_order', 'toggle_custom_menu_order' );
    add_filter( 'menu_order', 'remove_those_menu_items' );
    };

    function toggle_custom_menu_order(){
    return true;
    }

    function remove_those_menu_items( $menu_order ){
    global $menu;
    $post_types = maybe_unserialize(REMOVE_POST_TYPES);
    foreach ( $menu as $mkey => $m ) {

    foreach ($post_types as $post_type) {
    $key = array_search( 'edit.php?post_type='.$post_type, $m );

    if ( $key )
    unset( $menu[$mkey] );
    }
    }
    return $menu_order;
    }

    Basically you could hide all of that and all you need to add to the theme's functions.php would be this:

    $post_types = array ('proofing_pages','testimonials');

    if (!defined('REMOVE_POST_TYPES')) define('REMOVE_POST_TYPES',maybe_serialize($post_types));

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.