0

i am building a job system which will store following data:

  • job title - post title
  • description - content
  • location - post meta / taxonomy
  • sector (it/sales & etc)- custom taxonomy
  • salary start - post meta
  • salary end - post meta
  • contact person - post meta
  • skills - post meta
  • and etc

so far i created a custom post type called jobs and taxonomy called sector and couple of meta fields.

now my question is, should I store locations as taxonomy or use meta field ? since location will have county and town. town being children of county, having said that this is not really needed or required.

other issue is that i need to able to search the following location, sector and salary fields.

if had two taxonomies (locations and sectors), is it possible to query both of them at once?

any ideas or advice is welcomed.

happy to provide more info if needed.

thanks.

1 Answer 1

1

When the question comes to what to use Post Type, Taxonomies, custom fields ? I find that the understanding what each one of them stands for helps make the selection easier so i use:

  • Post types - for all major data records that need/not to be displayed or queried.
  • Taxonomies - for grouping posts/custom records together (with children) , helps a lot in queries.
  • Custom fields - for extra data that needs to be specific per post/custom record ,maybe even to help in queries.

So in your case i would use:

  • job title - post title
  • description - content
  • location - Custom Taxonomy (hirirchal)
  • sector - Custom Taxonomy
  • salary start - post meta
  • salary end - post meta
  • contact person - post meta
  • skills - post meta maybe even a custom taxonomy (depends on your needs)

As for searching based on a mix of them its actually easier then it sounds :

$args = array(
    'post_type' => 'job',
    'posts_per_page' => -1,
    'tax_query' => array( //this is for taxonomies
        'relation' => 'AND',
        array( //For location we use
            'taxonomy' => 'location',
            'field' => 'slug',
            'terms' => array( 'florida', 'san-antonio' )
        ),
        array(//for sector we use
            'taxonomy' => 'sector',
            'field' => 'slug',
            'terms' => array( 'it' ),
            'operator' => 'NOT IN'
        )
    ),
    'meta_query' => array( //this is for post meta
       array(//lets say 10000 and above
           'key' => 'salary_start',
           'value' => array(10000),
           'compare' =>  '>=',
           'type' => 'NUMERIC'
       )
   )
);
$query = new WP_Query( $args );
1
  • 1
    thanks for your reply, kinda silly question in the end as the answer was clear..... Oct 26, 2012 at 20:27

Your Answer

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

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