Displaying expired job posts

New in version 2.2.0 is the option to display expired job posts.

To show expired job posts on your wordpress site you first need to define the number of expired job posts you want the API to fetch.

When allowing API to fetch expired job posts you might experience that an API call to our server takes longer time. The RecMan API will fetch all job posts ever existed, but the Bonsy API will reduce the list into the number of jobposts you have defined.

To show a feed of expired job posts, you only need to replace the have_jobposts() method with have_expired_jobposts(). Like this:

<?php

# Check if there are any job posts available
if( have_expired_jobposts() ) :

     # loop through job posts
    while( have_expired_jobposts() ) : the_jobpost();

        # Print the job post title
        the_jobpost('title');

    endwhile;

else :

    echo "No job posts available.";

endif;

?>

Limit the number of job posts to display

You can also limit the feed by adding a count (integer) as the first parameter:

if( have_expired_jobposts(10) ) :
    ....

Remember to reset the loop

Remember that if you want to display multiple feeds on your WordPress site, you need to call the reset_jobpost_loop() method before adding a new loop.

<?php

if( have_jobposts() ) :
    while( have_jobposts() ) : the_jobpost();
        the_jobpost('title');
    endwhile;
endif;

reset_jobpost_loop();

if( have_expired_jobposts() ) :
    while( have_expired_jobposts() ) : the_jobpost();
        the_jobpost('title');
    endwhile;
endif;

?>

Limitation

Expired job posts will not work with filtering and search. Also, methods like get_jobpost_count() doesn't count expired job posts. Permalinks does work.

If you have activated the option to show single job post on your WordPress site you might consider using the field isExpired to check if the job post showing has expired. An expired job post will use the same template as an active job post when showing the job post page.

Last updated