I have a custom post type called dramas

/******* DRAMAS BEGIN *****************************************/
register_post_type('dramas', array(
    'label' => 'Dramas',
    'show_ui' => true,
    'supports' => array('title', 'thumbnail', 'description'),
    'labels' => array (
        'name' => 'Dramas',
        'singular_name' => 'Drama',
        'menu_name' => 'Dramas'
    'rewrite' => array( 'slug' => 'drama' ),
) );

I have set up a custom taxonomy for the post

/* register taxonomy only for DRAMAS*/
        'hierarchical' => true,
        'label' => 'Category',
        'query_var' => true,
        'rewrite' => true

I am able to get these post anywhere using following code

    $args = array( 'post_type' => 'dramas', 'posts_per_page' => 4 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();                           
    $image_id = get_post_thumbnail_id();
    $image_url = wp_get_attachment_image_src($image_id,'drama_realityshow_home_page_thumb', true);  
    $terms = get_the_terms( $post->ID, 'drama_taxonomy' ); 
<div class="prime-item">
  <a href="<?php the_permalink(); ?>" target="_blank" class="standard-height">
    <img src="<?php echo $image_url[0]; ?>" width="300" height="168" class="hoverZoomLink">
  <div class="new-cat"><?php 
    foreach($terms as $term) {
      echo $term->name;
    } ?>
<?php endwhile; ?>

By using the above code I am getting dramas custom post type's

  1. Thumbnail source
  2. Taxonomy term
  3. Permalink

When I hover over the I see the permalink / url www.mysite.com/drama/post-name at the browser bottom as I expected. But when I click on the link [ 'a' tag in the <div class="prime-item">] I am getting 404 page.

I have single-dramas.php in the theme folder. Even if I don not have that it should fall to single.php but it's not.

The browser address bar shows www.mysite.com/drama/post-name but displaying 404.

Also permalink edit option is NOT found at the right bottom of the editor title as always it's appeared.


why is this? How can I get to single page / the permalink works for the post type dramas? NOT to go to 404.

  • You will need to save permalink settings again. – Robert hue Sep 9 '15 at 6:19
  • I've tried that by visiting to Admin Panel -> Setting -> Permalinks and clicked save but NO luck.. still same 404 – Foolish Coder Sep 9 '15 at 6:26

You custom post type is NOT public.

Add following lines to your register_post_type array

'public' => true,
'publicly_queryable' => true, 

Your custom post type is not publicly visible so you need to update your argument

You can refer given link for that https://codex.wordpress.org/Function_Reference/register_post_type

And if your custom post type publicly visible and still problem exist please Flush your permalink and try it. It will solve your problem.

  • thanks .. as I mentioned in comment I already flushed my permalinks.. I upvoted you.. thanks for the time... – Foolish Coder Sep 9 '15 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.