hide expired jobs from joblist

Hi, I want to hide expired jobs. I tried the code from an other thread and copied it into my functions.php:
add_filter( 'jbp_job_search_params', 'exclude_expires_job' );
function exclude_expires_job( $args ) {
$jobs = JE_Job_Model::model()->all();
foreach ( $jobs as $job ) {
if($job->is_expired()){
$args['post__not_in'][]=$job->id;
}
}

return $args;
}

This code does not work on my site.
How do I disable expired jobs automatically?

Thanks and kind regards

  • Nastia
    • Support Rock Star

    Hello FLYINGFOX ,

    Hope you're doing well!

    I've just tested this code as mu-plugin and it worked from my end. Please upload the attached file to /wp--content/mu-plugins/ folder and try again.

    If the mu-plugins doesn't exist, feel free to create it.

    Let me know how it went!

    Kind regards,
    Nastia

  • FLYINGFOX
    • Site Builder, Child of Zeus

    The code does not work. It hides all jobs. Also jobs which are not expired from the archive page. I want to see only active jobs on all job sites. Expired jobs doesn't matters. This is something which should be in the preference of the plugin. Can someone tell me exactly how to do?

    thx for any help. kind regards R.

  • Denitsa
    • WordPress Warrior

    Hey there FLYINGFOX,
    I trust you're well :slight_smile:

    Looks like we'll need to ping the developer here, as he was the one to come up with that code workaround to start with. It may take a little while for him to check this and provide a solution, since devs work round the clock and they have to deal with lots of critical issues and other things.

    I appreciate your patience!

    Cheers,
    Denitsa

  • Nastia
    • Support Rock Star

    Hello FLYINGFOX

    Hope you're doing well!

    Sorry to hear the first script didn't work as it should be. Please try the following solution.

    Replace the attached main.php file with the main.php file in this directory:

    /wp-content/plugins/jobs-plus/app/views/job-archive/

    I've tested it on my site and it does hide only expired jobs. Please, not that the changes are made within the plugin's core files. So this feature will be load after the plugin's update. To bring it back, you will need to re-upload this file again.

    Also, please run a full backup of your site before making any changes.

    Let me know how it went!

    Kind regards,
    Nastia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.