Allow expired jobs to be indexed in search engines
By default, RecPress will set a nonidex
flag on jobs that have expired. This should have the desired effect of them eventually being removed from search engines indexes.
If you would like expired jobs to continue to be indexed in search engine result, you can add the following code to your active themes function.php
file or add it in a plugin.
<?php
/**
* Prevent expired jobs from having noindex.
*
* @param boolean $index_job_listing Whether to index the job listing or not.
* @param WP_Post $post The job listing post object.
*
* @return boolean Whether to index the job listing or not.
*/
function hd_allow_expired_jobs_to_index( $index_job_listing, $post ) {
// if this is not a job listing.
if ( 'job_listing' !== $post->post_type ) {
return $index_job_listing;
}
// if this is an expired job.
if ( 'expired' === $post->post_status ) {
$index_job_listing = true;
}
// return whether we are indexing the job or not.
return $index_job_listing;
}
add_filter( 'wpjm_allow_indexing_job_listing', 'hd_allow_expired_jobs_to_index', 10, 2 );