Skip to content

Expired Job Posts

You can display recently expired job posts alongside or separately from active ones.

First, configure how many expired job posts the API should fetch. This is set in the plugin’s fetch settings (stored on the Bonsy server). Contact Bonsy or use the admin dashboard to set the number of expired jobs to retain.

Use the have_expired_jobposts() function instead of have_jobposts():

<?php if (have_expired_jobposts()): ?>
<?php while (have_expired_jobposts()): the_jobpost(); ?>
<div class="expired-job">
<h3><?php the_jobpost('title'); ?></h3>
<p><?php the_jobpost('excerpt'); ?></p>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>No expired job posts.</p>
<?php endif; ?>

Pass an integer to limit how many expired jobs are shown:

<?php if (have_expired_jobposts(10)): ?>
<!-- Shows max 10 expired jobs -->
<?php endif; ?>

When showing both feeds on the same page, call reset_jobpost_loop() between them:

<?php
// Active jobs
if (have_jobposts()):
while (have_jobposts()): the_jobpost();
the_jobpost('title');
endwhile;
endif;
// Reset the loop before starting a new one
reset_jobpost_loop();
// Expired jobs
if (have_expired_jobposts()):
echo '<h2>Previously Listed Positions</h2>';
while (have_expired_jobposts()): the_jobpost();
the_jobpost('title');
endwhile;
endif;
?>