I created a custom post type with the following code:

add_action('init', 'create_trans_career');

function create_trans_career() {
    //Arguments to create post type.
    $args = array(
        'labels' => array(
            'name' => __('Career', 'trans'),
            'singular_name' => __('Career', 'trans'),
            'add_new' => __('Add New', 'trans'),
            'add_new_item' => __('Add New Career Item', 'trans'),
            'edit' => __('Edit', 'trans'),
            'edit_item' => __('Edit Career Item', 'trans'),
            'new_item' => __('New Career', 'trans'),
            'view' => __('View', 'trans'),
            'view_item' => __('View Career', 'trans'),
            'search_items' => __('Search Career', 'trans'),
            'not_found' => __('No Career item found', 'trans'),
            'not_found_in_trash' => __('No Career item found in Trash', 'trans'),
        'public' => true,
        'show_ui' => true,
        'capability_type' => 'post',
        'hierarchical' => true,
        'has_archive' => true,
        'menu_icon' => get_bloginfo('template_directory'). '/images/career-icon.png',
        'supports' => array('title', 'editor', 'thumbnail'),
        'rewrite' => array('slug' => 'career', 'with_front' => false),

    //Register type and custom taxonomy for type.
    register_post_type( 'career' , $args );

I also created a single page (single-career.php):

<?php while ( have_posts() ) : the_post(); ?>
            <h2 class="page-title"><?php the_title(); ?></h2>
            <hr />
            <?php the_content('Read More...'); ?>
            <a href="<?php bloginfo('wpurl'); ?>/career" title="<?php _e('Back to jobs listings', 'trans'); ?>" class="back-to-jobs"><?php _e('Back to jobs listings', 'trans'); ?></a>
            <?php endwhile;  ?>

..and a page template to list the posts:

$mypost = array( 'post_type' => 'career', 'posts_per_page' => 10, 'paged' => $pagedNum );
            $loop = new WP_Query( $mypost ); ?>
            <?php while ( $loop->have_posts() ) : $loop->the_post();?>
            <tr id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <td><?php the_title(); ?></td>
                <td><?php echo $location; ?></td>
                <td><?php echo $close_date; ?></td>
                <td><a href="<?php the_permalink(); ?>" title="<?php _e('Details', 'trans'); ?>"><?php _e('&gt; Details', 'trans'); ?></a></td>
                <td class="apply-now"><a data-title="<?php the_title(); ?>" data-location="<?php echo $location; ?>" href="#apply_<?php the_ID(); ?>" title="<?php _e('Apply Now', 'trans'); ?>" class="career-apply"><?php _e('Apply Now', 'trans'); ?></a></td>
            <?php endwhile;  ?>

I created a page with jobs using the template above.. it's working I see all posts.. but when I open a single page I receive 404 error. Where is the problem?

  • 1
    What URL is it trying to reach when it 404s?
    – vancoder
    Apr 9, 2013 at 21:57
  • 4
    Did you refresh permalink settings?
    – Chris_O
    Apr 9, 2013 at 21:59
  • career/test-job-title
    – Rinoleti
    Apr 9, 2013 at 21:59
  • How can I refresh and why is it necessary?
    – Rinoleti
    Apr 9, 2013 at 22:00
  • 1
    To refresh simply visit the permalinks page in settings. It will make sure all of your pretty permalinks (including /career/) are upto date.
    – vancoder
    Apr 9, 2013 at 22:11

3 Answers 3


Add this to your functions.php:

/* Flush rewrite rules for custom post types. */
add_action( 'after_switch_theme', 'bt_flush_rewrite_rules' );

/* Flush your rewrite rules */
function bt_flush_rewrite_rules() {

Then change your theme to a different theme and then set it back again to your custom theme. This will flush the rewrite rule and making the custom post working properly.

  • followed your instructions but not working :(
    – itskawsar
    May 2, 2014 at 13:22
  • it worked for me
    – chaim
    Oct 22, 2015 at 14:54
  • 1
    You could just go to your permalink settings and press save to flush your rewrite rules. This is a very weird and unnecessary workaround.
    – berentrom
    Apr 26, 2016 at 13:28

@welbyaudry solution works but the process is a bit lengthy. I want to make it simpler for others. Just place the below code in the functions.php of your active theme and refresh your page.

/* Flush rewrite rules for custom post types. */
add_action( 'init', 'bt_flush_rewrite_rules' );

/* Flush your rewrite rules */
function bt_flush_rewrite_rules() {



It seems like there are lots of different problems and potential solutions here, but after trying every other suggested solution, none of which worked, I found something that worked. Add:


after you call register_post_type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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