Title: single-{post-type}.php Help! Not working!
Last modified: August 20, 2016

---

# single-{post-type}.php Help! Not working!

 *  [Zen Jin Gonzaga](https://wordpress.org/support/users/zen-jin-gonzaga/)
 * (@zen-jin-gonzaga)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/single-post-typephp-help-not-working/)
 *     ```
       add_action( 'init', 'register_taxonomy_product_category' );
   
       function register_taxonomy_product_category() {
   
           $labels = array(
               'name' => _x( 'Product Categories', 'product category' ),
               'singular_name' => _x( 'Product Category', 'product category' ),
               'search_items' => _x( 'Search Product Categories', 'product category' ),
               'popular_items' => _x( 'Popular Product Categories', 'product category' ),
               'all_items' => _x( 'All Product Categories', 'product category' ),
               'parent_item' => _x( 'Parent Product Category', 'product category' ),
               'parent_item_colon' => _x( 'Parent Product Category:', 'product category' ),
               'edit_item' => _x( 'Edit Product Category', 'product category' ),
               'update_item' => _x( 'Update Product Category', 'product category' ),
               'add_new_item' => _x( 'Add New Product Category', 'product category' ),
               'new_item_name' => _x( 'New Product Category Name', 'product category' ),
               'separate_items_with_commas' => _x( 'Separate product categories with commas', 'product category' ),
               'add_or_remove_items' => _x( 'Add or remove product categories', 'product category' ),
               'choose_from_most_used' => _x( 'Choose from the most used product categories', 'product category' ),
               'menu_name' => _x( 'Product Categories', 'product category' ),
           );
   
           $args = array(
               'labels' => $labels,
               'public' => true,
               'show_in_nav_menus' => true,
               'show_ui' => true,
               'show_tagcloud' => false,
               'hierarchical' => true,
       		'rewrite' => array( 'slug' => 'product', 'with_front' => false ),
               'query_var' => true
           );
   
           register_taxonomy( 'product_category', array('product'), $args );
       }
   
       add_action( 'init', 'register_cpt_product' );
   
       function register_cpt_product() {
   
           $labels = array(
               'name' => _x( 'Products', 'product' ),
               'singular_name' => _x( 'Product', 'product' ),
               'add_new' => _x( 'Add New', 'product' ),
               'add_new_item' => _x( 'Add New Product', 'product' ),
               'edit_item' => _x( 'Edit Product', 'product' ),
               'new_item' => _x( 'New Product', 'product' ),
               'view_item' => _x( 'View Product', 'product' ),
               'search_items' => _x( 'Search Products', 'product' ),
               'not_found' => _x( 'No product found', 'product' ),
               'not_found_in_trash' => _x( 'No products found in Trash', 'product' ),
               'parent_item_colon' => _x( 'Parent Product:', 'product' ),
               'menu_name' => _x( 'Products', 'product' ),
           );
   
           $args = array(
               'labels' => $labels,
               'hierarchical' => false,
               'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'custom-fields' ),
               'taxonomies' => array( 'post_tag', 'product_category'  ),
               'public' => true,
               'show_ui' => true,
               'show_in_menu' => true,
               'menu_position' => 5,
               'menu_icon' => 'http://localhost/homenhaven/wp-content/themes/homenhaven/images/homenhaven-icon.png',
               'show_in_nav_menus' => false,
               'publicly_queryable' => true,
               'exclude_from_search' => false,
               'has_archive' => true,
               'query_var' => true,
               'can_export' => true,
               'rewrite' => array( 'hierarchical' => true, 'slug' => 'product', 'with_front' => false ),
               'capability_type' => 'post'
           );
   
           register_post_type( 'product', $args );
       }
       ```
   
 * Above is the Custom Post Type “Product”. and here below is single-product.php
   it’s not working. It doesn’t show any posts.
 *     ```
       <?php get_header(); ?>
   
       		<div id="primary">
       			<div id="content" role="main">
   
       			<?php if ( have_posts() ) : ?>
   
       				<?php /* Start the Loop */ ?>
       				<?php while ( have_posts() ) : the_post(); ?>
   
                           <?php the_date(); ?>
                           <?php the_content(); ?>
   
       				<?php endwhile; ?>
   
       			<?php else : ?>
   
       					<div class="entry-content">
       						<p>Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.</p>
       						<?php get_search_form(); ?>
       					</div><!-- .entry-content -->
   
       			<?php endif; ?>
   
       			</div><!-- #content -->
       		</div><!-- #primary -->
   
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   
 * Please help me cause i can’t figure out what i’m doing wrong. Please. Please.

The topic ‘single-{post-type}.php Help! Not working!’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [single.php](https://wordpress.org/support/topic-tag/single-php/)

 * 0 replies
 * 1 participant
 * Last reply from: [Zen Jin Gonzaga](https://wordpress.org/support/users/zen-jin-gonzaga/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/single-post-typephp-help-not-working/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
