Title: My plugin = WSOD
Last modified: August 21, 2016

---

# My plugin = WSOD

 *  [nickmoyer](https://wordpress.org/support/users/nickmoyer/)
 * (@nickmoyer)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/my-plugin-wsod/)
 * I followed this [tutorial](http://wp.tutsplus.com/tutorials/plugins/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes/)
   I thought very closely but when I finished it, my plugin works but it gives every
   other page on the site the WSOD! Once I deactivate the plugin, my other pages
   work again. I am running this on my mac using MAMP if that helps at all. I wanted
   to get it all finished before I upload and test online even though my site isn’t
   live.
 * Below is my code. Any ideas on what the heck I did wrong? Thank you so much for
   any help you can give me.
 *     ```
       <?php
       /*
       Plugin Name: NM Portfolio
       Plugin URI: http://work.nickmoyer.net
       Description: Declares a plugin that will create a custom post type displaying movie reviews.
       Version: 1.3
       Author: Nick Moyer
       Author URI: http://work.nickmoyer.net
       License: GPLv2
       */
   
       // Create a Custom Post Type
   
       add_action( 'init', 'create_nm_portfolio' );
   
       function create_nm_portfolio() {
       	register_post_type( 'nm_portfolio',
       		array(
       			'labels' => array(
       			'name' => 'NM Portfolio',
       			'singular_name' => 'NM Portfolio',
       			'add_new' => 'Add New',
       			'add_new_item' => 'Add New Portfolio Project',
       			'edit' => 'Edit',
       			'edit_item' => 'Edit Portfolio Project',
       			'new_item' => 'New Portfolio Project',
       			'view' => 'View',
       			'view_item' => 'View Portfolio Project',
       			'search_items' => 'Search Portfolio Projects',
       			'not_found' => 'No Portfolio Projects found',
       			'not_found_in_trash' =>
       			'No Portfolio Projects found in Trash',
       			'parent' => 'Parent Portfolio Project'
       		),
       			'public' => true,
       			'menu_position' => 15,
       			'supports' =>
       			array( 'title', 'editor', 'thumbnail' ),
       			'rewrite' => array('slug' => 'portfolio'),
       			'taxonomies' => array( '' ),
       			'has_archive' => true
       		)
       	);
       }
   
       // Creating Meta Box Fields for Custom Post Types
   
       add_action( 'admin_init', 'my_admin' );
   
       function my_admin() {
       	add_meta_box( 'nm_portfolio_cleint_meta_box','Portfolio Project Client Info','display_nm_portfolio_client_meta_box','nm_portfolio', 'normal', 'high' );
       }
   
       function display_nm_portfolio_client_meta_box( $nm_portfolio ) {
       	// Retrieve current name of the Director and Movie Rating based on review ID
       	$nm_clients = esc_html( get_post_meta( $nm_portfolio->ID,'nm_clients', true ) );
       	?>
       	<table>
       		<tr>
       			<td style="width: 100%">Client Name</td>
       			<td>
                   	<input type="text" size="80" name="nm_portfolio_clients" value="<?php echo $nm_clients; ?>" />
       			</td>
       		</tr>
       	</table>
       <?php }
   
       add_action( 'save_post','add_nm_portfolio_fields', 10, 2 );
   
       function add_nm_portfolio_fields( $nm_portfolio_id,$nm_portfolio ) {
       	// Check post type for movie reviews
       	if ( $nm_portfolio->post_type == 'nm_portfolio' ) {
       	// Store data in post meta table if present in post data
       	if ( isset( $_POST['nm_portfolio_clients'] ) && $_POST['nm_portfolio_clients'] != '' ) {
       		update_post_meta( $nm_portfolio_id, 'nm_clients', $_POST['nm_portfolio_clients'] );
       	}
       }
   
       }
       // Custom Template Dedicated to Custom Post Types
   
       add_filter( 'template_include','include_template_function', 1 );
   
       function include_template_function( $template_path ) {
           if ( get_post_type() == 'nm_portfolio' ) {
               if ( is_single() ) {
                   // checks if the file exists in the theme first,
                   // otherwise serve the file from the plugin
                   if ( $theme_file = locate_template( array ( 'single-nm_portfolio.php' ) ) ) {
                       $template_path = $theme_file;
                   } else {
                       $template_path = plugin_dir_path( __FILE__ ) . '/single-nm_portfolio.php';
                   }
               }
       			elseif ( is_archive() ) {
       		if ( $theme_file = locate_template( array ( 'archive-nm_portfolio.php' ) ) ) {
       			$template_path = $theme_file;
       		} else { $template_path = plugin_dir_path( __FILE__ ) . '/archive-nm_portfolio.php';
   
       		}
           }
           return $template_path;
       }
   
       // Displaying Additional Columns
   
       add_filter( 'manage_edit-nm_portfolio_columns', 'my_columns' );
   
       function my_columns( $columns ) {
           $columns['nm_portfolio_clients'] = 'Clients';
           unset( $columns['comments'] );
           return $columns;
       }
   
       add_action( 'manage_posts_custom_column', 'populate_columns' );
   
       function populate_columns( $column ) {
           if ( 'nm_portfolio_clients' == $column ) {
               $nm_clients = esc_html( get_post_meta( get_the_ID(), 'nm_clients', true ) );
               echo $nm_clients;
           }
       }
   
       add_filter( 'manage_edit-nm_portfolio_sortable_columns', 'sort_me' );
   
       function sort_me( $columns ) {
           $columns['nm_portfolio_clients'] = 'nm_portfolio_clients';
           return $columns;
       }
   
       add_filter( 'request', 'column_ordering' );
   
       add_filter( 'request', 'column_orderby' );
   
       function column_orderby ( $vars ) {
           if ( !is_admin() )
               return $vars;
           if ( isset( $vars['orderby'] ) && 'nm_portfolio_clients' == $vars['orderby'] ) {
               $vars = array_merge( $vars, array( 'meta_key' => 'nm_clients', 'orderby' => 'meta_value' ) );
       	}
           return $vars;
       }
   
       //Creating Filters With Custom Taxonomy
   
       add_action( 'restrict_manage_posts', 'my_filter_list' );
   
       function my_filter_list() {
           $screen = get_current_screen();
           global $wp_query;
           if ( $screen->post_type == 'nm_portfolio' ) {
               wp_dropdown_categories( array(
                   'show_option_all' => 'Show All Movie Genres',
                   'taxonomy' => 'movie_reviews_movie_genre',
                   'name' => 'movie_reviews_movie_genre',
                   'orderby' => 'name',
                   'selected' => ( isset( $wp_query->query['movie_reviews_movie_genre'] ) ? $wp_query->query['movie_reviews_movie_genre'] : '' ),
                   'hierarchical' => false,
                   'depth' => 3,
                   'show_count' => false,
                   'hide_empty' => true,
               ) );
           }
       }
   
       add_filter( 'parse_query','perform_filtering' );
   
       function perform_filtering( $query ) {
           $qv = &$query->query_vars;
           if ( ( $qv['movie_reviews_movie_genre'] ) && is_numeric( $qv['movie_reviews_movie_genre'] ) ) {
               $term = get_term_by( 'id', $qv['movie_reviews_movie_genre'], 'movie_reviews_movie_genre' );
               $qv['movie_reviews_movie_genre'] = $term->slug;
           }
       }
       }
   
       // Adding Taxonomies
   
       add_action( 'init', 'create_my_taxonomies', 0 );
   
       function create_my_taxonomies() {
           register_taxonomy(
               'nm_portfolio_service_type',
               'nm_portfolio',
               array(
                   'labels' => array(
                       'name' => 'Services Performed',
                       'add_new_item' => 'Add New Service',
                       'new_item_name' => "New Service Type"
                   ),
                   'show_ui' => true,
                   'show_tagcloud' => false,
                   'hierarchical' => true
               )
           );
       	register_taxonomy(
               'nm_portfolio_programs_used',
               'nm_portfolio',
               array(
                   'labels' => array(
                       'name' => 'Programs Used',
                       'add_new_item' => 'Add New Program',
                       'new_item_name' => "New Program"
                   ),
                   'show_ui' => true,
                   'show_tagcloud' => false,
                   'hierarchical' => true
               )
           );
       	register_taxonomy(
               'nm_portfolio_equipment_used',
               'nm_portfolio',
               array(
                   'labels' => array(
                       'name' => 'Equipment Used',
                       'add_new_item' => 'Add New Equipment',
                       'new_item_name' => "New Equipment"
                   ),
                   'show_ui' => true,
                   'show_tagcloud' => false,
                   'hierarchical' => true
               )
           );
   
       }
       ?>
       ```
   

The topic ‘My plugin = WSOD’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [WSOD](https://wordpress.org/support/topic-tag/wsod/)

 * 0 replies
 * 1 participant
 * Last reply from: [nickmoyer](https://wordpress.org/support/users/nickmoyer/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/my-plugin-wsod/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
