} else if ($job_id) {
$this->show_job($job_id);
} else {
- $this->search_form();
+ $number_of_jobs = $this->get_number_of_jobs();
+ if ($number_of_jobs) {
+ $this->search_form();
+ }
$this->list_jobs();
}
$output = ob_get_contents();
return;
}
+ public function get_number_of_jobs()
+ {
+ global $wpdb, $wp;
+ $midnight = strtotime(date('Y-m-d',time()).' 00:00:00');
+ $args = array(
+ 'post_type' => GLM_EMP_POST_TYPE,
+ 'meta_query' => array(
+ array(
+ 'key' => 'glm_jobs_enddate',
+ 'value' => $midnight,
+ 'compare' => '>='
+ ),
+ array(
+ 'key' => 'glm_jobs_startdate',
+ 'value' => $midnight,
+ 'compare' => '<='
+ )
+ )
+ );
+ $jobs = get_posts($args);
+ return count($jobs);
+ }
+
/**
* List the jobs that are currently set to display
* based on start and end dates
<div><strong>Status: </strong><?php echo $job->glm_jobs_status;?></div>
<div><a href="<?php echo $job->href;?>">Full Job Description</a></div>
</div>
- <?php endforeach; endif;?>
+ <?php endforeach;?>
+ <?php else:?>
+ <h3>There are currently no positions available.</h3>
+ <?php endif;?>
</div>
</div>