Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This my Custom Post Type Code

/* Job Opening */
add_action( 'init', 'create_job_opening' );
function create_job_opening() {
    register_post_type( 'job_opening',
        array(
            'labels' => array(
                'name' => 'Job Opening',
                'singular_name' => 'Job Opening',
                'add_new' => 'Add New',
                'add_new_item' => 'Add New Job Opening',
                'edit' => 'Edit',
                'edit_item' => 'Edit Job Opening',
                'new_item' => 'New job opening',
                'view' => 'View',
                'view_item' => 'View job opening',
                'search_items' => 'Search job opening',
                'not_found' => 'No Job Opening found',
                'not_found_in_trash' => 'No Job Opening found in Trash',
                'parent' => 'Parent job opening'
            ),

            'public' => true,
            'menu_position' => 15,
            'supports' => array( 'title', 'editor', 'thumbnail' ),
            'taxonomies' => array( '' ),
            'menu_icon' => get_bloginfo('template_directory') . '/images/Careerpost-icon.png',  // Icon Path
            'has_archive' => true
        )
    );
}
add_action( 'admin_init', 'my_admin_job' );

function my_admin_job() {
    add_meta_box( 'job_opening_meta_box',
        'job Details',
        'display_job_opening_meta_box',
        'job_opening', 'normal', 'high'
    );
}

I can call my post to sidebar

$args = array( 'post_type' => 'job_opening', 'posts_per_page' => 30 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
    the_title();
endwhile;

my single.php is blank now. how can i create a job-single-post.php how to specify job-single-post.php is the single post template for job_opening CPT?.

share|improve this question
add comment

1 Answer

WordPress uses a naming pattern that determines what template gets used to display a certain kind of content.

In your case, all you need to do is create a template file with a standard loop and name it single-job_opening.php. This will ensure that this file gets loaded when the user views a single job opening post. You can find out more about this here: http://codex.wordpress.org/Template_Hierarchy

I recommend that you use the Debug Bar Plugin (http://wordpress.org/extend/plugins/debug-bar/) when running into similar problems in the future. Not only will it tell what template is loaded on what page, but it also gives you an indication of what content type is loaded.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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