Support » Fixing WordPress » Custom Post Type – Job Board

  • Hi, I was wondering if anyone has any pointers of how to create a custom post type for a job board.

    I need to create this for my client but not really sure where to start as have just been reading up on the subject. My client is after the following;

    Job Listings Page – This will display just like a news feed of all the latest jobs
    Job Description Page – This will be similar to the single blog post page

    For each job post, he needs to be able to add the following;

    • Job Title
    • Employer
    • Location
    • Position Type
    • Salary
    • A brief description or summary
    • A Logo of the company advertising the job
    • Date Posted
    • Expiry Date

    A great example of this would be here.

    Once the user clicks on the job post, it will take them to the actual job post content which will just be all the details as above but including a long description of the job advertised and a link which will take the user to the adverts company website.

    So… can this be done easily? Am I trying to do something that is too hard for a first attempt or am I just over thinking it?

    Any pointers or help would be awesome, as I really need to get moving with this add-on as I’ve been putting it off for ages.

    Many thanks guys.

    Alex

Viewing 4 replies - 1 through 4 (of 4 total)
  • If you do not have problems with plugins, I recommend: Pods – Custom Content Types and Fields (it’s a WordPress plugin, easy to use and the documentation should get you where you need to be…)

    Thread Starter SEO Sheikh

    (@webfeetdesign)

    Cheers Archie22is. I ended up making my own but can’t seem to get it to display in the front end. Looks good in the admin and all seems to be working ok.

    See this thread I started for where I managed to get to –

    Cheers

    Thread Starter SEO Sheikh

    (@webfeetdesign)

    Sorry that didn’t work for some reason… this is the code I’ve used;

    <?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 usually use a custom loop to retrieve my custom content, see example below:

    <?php
    /**
     * Template Name: Gallery Page (Custom)
     * Description: A full-width template with no sidebar
     */
    get_header(); ?>
    
        <div id="content" class="clearfix">
    
            <div id="main" class="clearfix" role="main">
    
    		<!-- Test static test -->
    		<h1><?php echo get_the_title(); ?></h1>
    
            <h2>Just a simple, plain and old school gallery using custom post types </h2>          
    
    	        <!-- CUSTOM LOOP -->
    	        <?php $my_loop = new WP_Query(
    	        		array(
    	        				'post_type' => 'gallery',
    	        				'posts_per_page' => 100
    	        			)
    	        		); 
    
    	        ?>
    
    			<?php while ( $my_loop->have_posts() ) : $my_loop->the_post(); ?>
    
    			<?php //the_post_thumbnail(); ?>
    
    				<h3><?php the_title() ?></h3>
    
    				<?php 
    
    					$image = get_post_meta($post->ID, 'upload' );
    
    					foreach ( $image as $img ) {
    						echo pods_image( $img, 'original' );
    					}
    
    				?>		
    
    			<?php endwhile; ?>
            	<!-- END OF LOOP -->
    
    		</div>
    	</div>
    
    <?php get_footer(); ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Post Type – Job Board’ is closed to new replies.