Function is available since WPJobBoard 3.5
This function is can be used for advanced jobs search, it allows to search: keyword, location, country, category, job type, additional fields, sort jobs and much more. Note that only active jobs are returned.
Default usage
$result = wpjb_find_jobs(array(
"query" => "",
"location" => "",
"country" => null,
"category" => null,
"type" => null,
"posted" => null,
"is_featured" => false,
"employer_id" => null,
"sort" => "job_created_at",
"order" => "DESC",
"page" => null,
"count" => null,
"field" => array()
));
Parameters
You can pass zero or more parameters to the function.
query – (string) search jobs by: keyword, company name, location
location – (string) search jobs by: city, state, country zip code
country – (int) search countries by country numeric code (available codes can be found in wpjobboard/application/config/country_list.ini
category – (mixed) can be both category id (int) or array of category ids
type – (mixed) can be both job type id (int) or array of job type ids
posted – (int) how many days ago job was posted (available values are: 1=Today; 2=Yesterday, 7=Less than 7 days ago, 30=Less than 30 days ago)
is_featured – (boolean) if true search will return featured jobs only
employer_id – (int) employer id from database table wpjb_employer
sort – (string) field to sort by (available are: “id”, “job_created_at”, “job_title”)
order – (string) either ASC (ascending) or DESC (descending)
page – (int) which page to display (for use with count parameter)
count – (int) number of jobs per page
field – (array) search by additional field, the parameter should contain array of key, value elements where key is additional field id and value is the value to search by, for example array(5 => "find-me")
Returned value
$result->job; // (array) of Wpjb_Model_Job objects
$result->page // (int) page number;
$result->perPage // (int) number of element per page;
$result->count // (int) number of jobs on this page;
$result->total // (int) total number of jobs found;
$result->url->feed // (string) url to custom rss for this search
$result->url->search // (string) url to search result
Examples
Searching jobs by keyword and displaying job link and title:
$result = wpjb_find_jobs(array("query"=>"php"));
foreach($result->job as $job) {
echo "<p>";
echo $job->job_title."<br/>";
echo wpjb_link_to("job", $job);
echo "</p>";
}