Single page not working for custom post type
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
tda 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
/tr
?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?
Topic single custom-post-types Wordpress
Category Web