Can't display my custom post type
-
Hi there, I’ve managed to create a custom type. It works ok in the backend but I can’t seem to get it to come through on the front end. My page is single-job.php and the code within it is this:
<?php while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <header class="entry-header"> <h2 class="entry-title"> <?php the_title(); ?> </h2> </header> <p class="job-meta"> Employer: <?php echo get_post_meta ($post->ID, 'job_employer', true); ?> </p> <div class="job-entry-content"> <?php the_content(); ?> </div> </article> <?php endwhile;// end of the loop ?>
My function code for the custom post type is:
// Custom Theme Type For Jacks Jobs Lists add_action('init', 'jobs_register'); function jobs_register() { $labels = array( 'name' => _x('Jobs', 'post type general name'), 'singular_name' => _x('Job Item', 'post type singular name'), 'add_new' => _x('Add New', 'job item'), 'add_new_item' => __('Add New Job Item'), 'edit_item' => __('Edit Job Item'), 'new_item' => __('New Job Item'), 'view_item' => __('View Job Item'), 'search_items' => __('Search Jobs'), 'not_found' => __('Nothing found'), 'not_found_in_trash' => __('Nothing found in Trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'menu_icon' => get_stylesheet_directory_uri() . '/article16.png', 'rewrite' => true, 'capability_type' => 'post', 'has_archive' => 'job', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','thumbnail','excerpt') ); register_post_type( 'jobs' , $args ); } register_taxonomy("position_type", array("jobs"), array("hierarchical" => true, "label" => "Position Type", "singular_label" => "Poistion Type", "rewrite" > true)); // add all data fields to the add/edit post page add_action("admin_init", "admin_init"); function admin_init(){ add_meta_box("job_employer_meta", "Employer", "job_employer", "jobs", "normal", "high"); add_meta_box("job_expiry_meta", "Job Expiry", "job_expiry", "jobs", "side", "low"); add_meta_box("location_meta", "Location", "job_location", "jobs", "normal", "high"); add_meta_box("salary_meta", "Salary", "job_salary", "jobs", "normal", "high"); } // add Employer data field to the add/edit post page function job_employer(){ global $post; $custom = get_post_custom($post->ID); $job_employer = $custom["job_employer"][0]; ?> <label>Job Employer:</label> <input name="job_employer" value="<?php echo $job_employer; ?>" /> <?php } // add Expiry data field to the add/edit post page function job_expiry(){ global $post; $custom = get_post_custom($post->ID); $job_expiry = $custom["job_expiry"][0]; ?> <label>Job Expiry Date:</label> <input name="job_expiry" value="<?php echo $job_expiry; ?>" /> <?php } // add Location data field to the add/edit post page function job_location(){ global $post; $custom = get_post_custom($post->ID); $job_location = $custom["job_location"][0]; ?> <label>Job Location:</label> <input name="job_location" value="<?php echo $job_location; ?>" /> <?php } // add Salary data field to the add/edit post page function job_salary(){ global $post; $custom = get_post_custom($post->ID); $job_salary = $custom["job_salary"][0]; ?> <label>Job Salary:</label> <input name="job_salary" value="<?php echo $job_salary; ?>" /> <?php } add_action('save_post', 'save_details'); function save_details(){ global $post; update_post_meta($post->ID, "job_employer", $_POST["job_employer"]); update_post_meta($post->ID, "job_expiry", $_POST["job_expiry"]); update_post_meta($post->ID, "job_location", $_POST["job_location"]); update_post_meta($post->ID, "job_salary", $_POST["job_salary"]); } ?>
I really don’t know where I’m going wrong with this!! Any help would be wicked..
Cheers
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Can't display my custom post type’ is closed to new replies.