I took out some parts but narrowed it down to this section below that was causing the problem.
// 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;
}
I deleted add_filter( 'template_include','include_template_function', 1 );
and it seems to work fine now.
Below is my code all together that works and has been edited to get rid of a few things that I didn't really want anyway.
<?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
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;
}
// 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
)
);
}
?>
Thanks for your help!