Custom post-type plugin I'm building causing a conflict and can't get to wp-admin

A custom post-type plugin I'm building is causing a conflict and can't get to wp-admin when it's turned on and also goes to blank screen when I'm updating posts if Im already logged in. It's definitely the plugin. I stripped most code out and started over from a lynda.com tutorial so it's not done, but hoping someone can help find the offending code as I can't. Thanks!!
Kate

<?php
/*
Plugin Name: Custom Posts Gallery
Plugin URI:N/A
Description: Declares a plugin that will create a custom post type displaying Selected Gallerys.
Version: 1.0
Author: Kate Eldridge
Author URI: http://kateeldridge.co/
License: GPLv2
*/

//Register custom function

// Function Implementation
function create_custom__gallery_post() {
  //Custom Post Type :: Selected Gallery
   $labels = array(
                'name' => 'Gallery',
                'singular_name' => ' Gallery',
                'add_new' => 'Add New',
                'add_new_item' => 'Add New Gallery',
                'edit' => 'Edit',
                'edit_item' => 'Edit Gallery',
                'new_item' => 'New Gallery',
                'view' => 'View',
                'view_item' => 'View Gallery',
                'search_items' => 'Search Galleries',
                'not_found' => 'No Galleries found',
                'not_found_in_trash' => 'No  Galleries found in Trash',
                'parent' => 'Parent  Gallery'
        );
    $args = array(
            'labels' => $labels,
            'public' => true,
            'menu_position' => 15,
            'supports' => array( 'title', 'editor', 'thumbnail'),
            'taxonomies' => array(''),
            'menu_icon' => 'dashicons-format-gallery',
            'rewrite' => array('slug' => 'Gallery'),
            'has_archive' => true,
            'show_ui' => true,
            'show_in_menu' => true
        );

register_post_type( 'gallery',$args);

//Custom Post Type :: Motion Gallery
 $labels = array(
                'name' => 'Motion Gallery',
                'singular_name' => 'Motion Gallery',
                'add_new' => 'Add New',
                'add_new_item' => 'Add New Motion Gallery',
                'edit' => 'Edit',
                'edit_item' => 'Edit Motion Gallery',
                'new_item' => 'New Motion Gallery',
                'view' => 'View',
                'view_item' => 'View Motion Gallery',
                'search_items' => 'Search Motion Galleries',
                'not_found' => 'No Motion Gallerys found',
                'not_found_in_trash' => 'No Motion Galleries found in Trash',
                'parent' => 'Parent Motion Gallery'
        );

    $args = array(
            'labels' => $labels,
            'public' => true,
            'menu_position' => 15,
            'supports' => array( 'title', 'editor', 'thumbnail'),
            'taxonomies' => array('category', 'post_tag'),
            'menu_icon' => 'dashicons-format-gallery',
            'rewrite' => array('slug' => 'motion'),
            'has_archive' => true,
            'show_ui' => true,
            'show_in_menu' => true
        );

register_post_type( 'motion_gallery',$args);

//Custom Post Type :: Commission Gallery

$labels = array(
                'name' => 'Commissions Gallery',
                'singular_name' => 'Commissions Gallery',
                'add_new' => 'Add New',
                'add_new_item' => 'Add New Commissions Gallery',
                'edit' => 'Edit',
                'edit_item' => 'Edit Commissions Gallery',
                'new_item' => 'New Commissions Gallery',
                'view' => 'View',
                'view_item' => 'View Commissions Gallery',
                'search_items' => 'Search Commissions Galleries',
                'not_found' => 'No Commissions Gallerys found',
                'not_found_in_trash' => 'No Commissions Galleries found in Trash',
                'parent' => 'Parent Commissions Gallery'
        );

    $args = array(
            'labels' => $labels,
            'public' => true,
            'menu_position' => 15,
            'supports' => array( 'title', 'editor', 'thumbnail'),
            'taxonomies' => array('category', 'post_tag'),
            'menu_icon' => 'dashicons-format-gallery',
            'rewrite' => array('slug' => 'commissions'),
            'has_archive' => true,
            'show_ui' => true,
            'show_in_menu' => true
        );

register_post_type( 'comissions_gallery',$args);

}

add_action( 'init', 'create_custom__gallery_post' );

function rewrite_flush(){
    create_custom__gallery_post();
    flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'rewrite_flush');

?>
  • Adam Czajczyk

    Hello Kate,

    I hope you're well today and thank you for your question!

    I've reviewed your code and tested it on my sandbox and I cannot see anything wrong with it. Also, it's working as expected - not blocking access to the "wp-admin" and properly registering post types. I was able to add and edit both "standard" posts and your custom posts.

    If I may though, I'd suggest adding this line right below "register_activation_hook()":

    register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );

    That said, I understand that you were able to narrow the source of the issue down to your plugin but are you 100% sure that this is the part that's causing trouble? Would you mind if I took a look at an entire code?

    Best regards,
    Adam

  • Adam Czajczyk

    Hello Kate,

    Thank you for your response!

    You're not able to attach .zip files here indeed. The simplest way would be to put the file on any "file hosting" server/cloud (e.g. Dropbox or Google docs) and share a link here with me. I understand however that you may want to not make it public yet so instead you may want to send me a link to download directly via our contact form here:

    https://premium.wpmudev.org/contact/.

    Please use "ATTN: Adam Czajczyk" as a subject line.

    Select "I have a different question" from the drop-down list and please include link back to this thread in your message.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.