UrbanPro
true

Learn WordPress from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Wordpress Plugin-How to show job count in job search.

Monali M.
27/06/2017 0 0

WP Job Manager is one of the famous job board in WordPress world. It provides option for Adding job from front-end. It gives a dashboard where user can check their posted job. Also a job directory where user can search the jobs.

Let’s talk about the job search. WPJM provides a shortcode called [jobs]. Here user can search job based on category, type and location etc. Well this works like a charm. But for our new project “Jobster“, we wanted to show job count on live job search. Let me explain how we have achieved this. it is very simple to do. Thanks to WPJM.

So we have to achieve it in three steps.

Step 1:

We need to over ride the job-listings-start.php. Please refer this article for it. https://wpjobmanager.com/document/template-overrides/ .

When you will move your job-listings-start.php file inside the theme like mytheme/job_manager/job-listings-start.php, you will find this.

<ul class="job_listings">

Now we need to edit it to  https://gist.github.com/kishoresahoo/77cdabcc46d5dfc2cf8baa34ed450a22

<h2 id="titlebar">Showing <span class="count_jobs"></span> Jobs</h2>
<ul class="job_listings">

Step 2:

Please open your theme function file and add this function. Here we hooking post_count to ajax parameter of job search. So in this way we will get the value of job count during live job search. https://gist.github.com/kishoresahoo/a3bc9e4e9805b39ac5b38485354c28f0

/*
 * @see WP_Job_Manager_Ajax class line 211 wp_send_json( apply_filters( 'job_manager_get_listings_result', $result, $jobs ) );
 * 
 */
function custom_job_manager_get_listings_result($result, $jobs) {
  $result['post_count'] = $jobs->found_posts;
  return $result;
}
add_filter( 'job_manager_get_listings_result', 'custom_job_manager_get_listings_result',10,2 );

Step 3:

Now we have the job count during ajax search. So we need to now display it as per our wish. So please open your theme js file or include new js file and then add the following code. https://gist.github.com/kishoresahoo/07e765c2538617d5e4fca0854e61c3db

/* add live job count on job search */
jQuery( document ).ready( function ( $ ) {

  $('div.job_listings').on('updated_results', (function(_this) {
      return function(event, results) {
          $('#titlebar .count_jobs').html(results.post_count);
      };
  })(this));

});
0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

5 proven tips to get noticed online.
If you’re thinking of launching a startup or small business you likely don’t have the budget to draw prospects to your site with expensive digital ads. The main problem when you are starting...


How to adjust the orders of the posts in word press ??
This topic covers about, how to order the word press posts ?? You created one website, there you inserted some posts in your website, you posted many postes at word press posts, if you want to change...

What is M.S.Project ?
MICROSOFT PROJECT contains project work and project groups, schedules and finances.Microsoft Project permits its users to line realistic goals for project groups and customers by making schedules, distributing...

WordPress Website Design Training Program Syllabus
What You will Learn in WordPress Website Design Training Program Introduction to CMS and WordPress Installation of WordPress Setting up WordPress on Local and Remote Server WordPress User...
X

Looking for WordPress Classes?

The best tutors for WordPress Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn WordPress with the Best Tutors

The best Tutors for WordPress Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more