Support » Fixing WordPress » Jobs and Locations Listings

  • Resolved rocomu8


    Hello all, I’m developing a website that has a “Locations” section and a “Jobs” section within it. Each one of these sections needs to have an archive page and a single post page for each Job / Location. The trick is that within each Location, I need to display the Jobs available at that particular location. I wanted to use Custom Post Types for each one, which is fine, but I do not know how to get the Jobs related to a particular Location to display in the Location single page.

    Any help would be greatly appreciated! I’ve been going round and round with this and no luck.

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You need to manipulate The Query.

    Can I assume that you have a Custom Post Type called ‘jobs’ and a Custom Taxonomy call ‘location’? If that is the case, you can make a tamplate called ‘index-jobs’. This template will be called to show a list of your jobs.

    At the top of the template you need to construct your query.

    /** Build the arguments to get all 'jobs' */
    $args = array(
        'numberposts' => -1,
        'posts_per_page' => get_option('posts_per_page'),
        'paged' => $paged,
        'post_status' => 'publish', // Add private, etc. if you wish
        'post_type' => 'jobs',
    /** Check that a Term from the 'location' Taxonomy has been parsed */
    $taxonomy = get_query_var('taxonomy');
    $term = get_query_var('term');
    if($taxonomy === 'location' && $term !== '') :
        $args[$taxonomy] = $term;
    /** Query the posts */

    Please note that this code is untested, so may require a few tweeks, and may contain the odd typo. However, it should set you on the right path. After this, you can display the results of the query as you so please.

    You could also look in to ‘taxonomy.php’. Assuming you are using pretty permalinks, this means that you could display posts using the scructure – this would display all posts that have the term London associated with them (if this is not just your ‘jobs’ post type, then you can again manipulate the query). When you didplay a list of locations, you link to the ‘taxonomy.php’ template using get_term_link($term, $taxonomy);Function Reference.

    Duck_boy, thank you very much for your suggestions. The issue here is that I need to have a Custom Post type for both Jobs and Locations. Each job and each location will have a detail page with different metaboxes (hours of operations etc…). So how can I associate certain job posts with a specific location? Any ideas?

    Thanks again!

    Ah, with you. I use a plugin called Post2Post by Scribu.

    You create a link in your ‘functions.php’ file, and then you literally link the posts to each other in the post edit screen. There are then all sorts of new arguments that you can add to your query to code to grab the posts you want.

    Scribu has a page for this plugin that offers tips for beginners and shows code for certain scenarios. He will also come on here and offer support should you hit problems.

    Duck_boy, thank you very much for your help, this worked like charm!

    No problem.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Jobs and Locations Listings’ is closed to new replies.