archive-jobpost.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. /**
  3. * The Template for displaying job archives, including the main jobpost page which is a post type archive.
  4. *
  5. * Override this template by copying it to yourtheme/simple_job_board/archive-jobpost.php
  6. *
  7. * @author PressTigers
  8. * @package Simple_Job_Board
  9. * @subpackage Simple_Job_Board/Templates
  10. * @version 1.1.0
  11. * @since 2.2.0
  12. * @since 2.2.3 Enqueued Front end Styles & Revised the HTML structure.
  13. * @since 2.2.4 Enqueued Front end Scripts.
  14. * @since 2.3.0 Added "sjb_archive_template" filter.
  15. * @since 2.4.0 Revised the whole HTML structure.
  16. * @since 2.4.6 Added missing parameters for pagination template.
  17. */
  18. get_header();
  19. ob_start();
  20. global $job_query, $post;
  21. /**
  22. * Enqueue Frontend Scripts.
  23. *
  24. * @since 2.2.4
  25. */
  26. do_action('sjb_enqueue_scripts');
  27. /**
  28. * Hook -> sjb_before_main_content
  29. *
  30. * @hooked sjb_job_listing_wrapper_start - 10
  31. * - Output Opening div of Main Container.
  32. * - Output Opening div of Content Area.
  33. *
  34. * @since 2.2.0
  35. * @since 2.2.3 Removed the content wrapper opening div
  36. */
  37. do_action('sjb_before_main_content');
  38. ?>
  39. <!-- Start Content Wrapper
  40. ================================================== -->
  41. <div class="sjb-page">
  42. <div class="sjb-archive-page">
  43. <!-- Start Job Title
  44. ================================================== -->
  45. <h3><span class="job-title"><?php echo apply_filters('sjb_jobs_archive_title', esc_html__('Job Archives', 'simple-job-board')); ?></span></h3>
  46. <!-- ==================================================
  47. End Job Title -->
  48. <?php
  49. // Retrieves Public Query Page Variable
  50. if (get_query_var('paged')) {
  51. $paged = (int) get_query_var('paged');
  52. } elseif (get_query_var('page')) {
  53. $paged = (int) get_query_var('page');
  54. } else {
  55. $paged = 1;
  56. }
  57. // WP_Query Default Arguments
  58. $args = apply_filters(
  59. 'sjb_archive_output_jobs_args', array(
  60. 'posts_per_page' => '15',
  61. 'post_type' => 'jobpost',
  62. 'paged' => $paged,
  63. )
  64. );
  65. // Merge WP_Query $args array on each $_GET element
  66. $args['jobpost_category'] = ( NULL != filter_input(INPUT_GET, 'selected_category') && -1 != filter_input(INPUT_GET, 'selected_category') ) ? sanitize_text_field(filter_input(INPUT_GET, 'selected_category')) : '';
  67. $args['jobpost_job_type'] = ( NULL != filter_input(INPUT_GET, 'selected_jobtype') && -1 != filter_input(INPUT_GET, 'selected_jobtype') ) ? sanitize_text_field(filter_input(INPUT_GET, 'selected_jobtype')) : '';
  68. $args['jobpost_location'] = ( NULL != filter_input(INPUT_GET, 'selected_location') && -1 != filter_input(INPUT_GET, 'selected_location') ) ? sanitize_text_field(filter_input(INPUT_GET, 'selected_location')) : '';
  69. $args['s'] = ( NULL != filter_input(INPUT_GET, 'search_keywords') ) ? sanitize_text_field( (filter_input(INPUT_GET, 'search_keywords') ) ) : '';
  70. // Job Query
  71. $job_query = new WP_Query($args);
  72. /**
  73. * Fires before listing jobs on job listing page.
  74. *
  75. * @since 2.2.0
  76. */
  77. do_action( 'sjb_job_filters_before' );
  78. /**
  79. * Template -> Job Filters:
  80. *
  81. * - Keywords Search.
  82. * - Job Category Filter.
  83. * - Job Type Filter.
  84. * - Job Location Filter.
  85. *
  86. * Search jobs by category, location, type and keywords.
  87. */
  88. get_simple_job_board_template( 'job-filters.php' );
  89. /**
  90. * Template -> Job Listing Start:
  91. *
  92. * - SJB Starting Content Wrapper div.
  93. */
  94. get_simple_job_board_template( 'listing/job-listings-start.php' );
  95. if ($job_query->have_posts()):
  96. global $counter;
  97. $counter = 1;
  98. while ($job_query->have_posts()): $job_query->the_post();
  99. /**
  100. * Hook -> sjb_job_listing_view
  101. *
  102. * @hooked sjb_job_listing_view - 10
  103. *
  104. * Display the user defined job listing view:
  105. *
  106. * - Either job listing grid view or list view.
  107. *
  108. * @since 2.2.3
  109. */
  110. do_action( 'sjb_job_listing_view' );
  111. endwhile;
  112. /**
  113. * Template -> Pagination:
  114. *
  115. * - Add Pagination to Resulted Jobs.
  116. */
  117. get_simple_job_board_template( 'listing/job-pagination.php', array( 'job_query' => $job_query ) );
  118. else:
  119. /**
  120. * Template -> No Job Found:
  121. *
  122. * - Display Message on No Job Found.
  123. */
  124. get_simple_job_board_template( 'listing/content-no-jobs-found.php' );
  125. endif;
  126. wp_reset_postdata();
  127. /**
  128. * Fires after listing jobs on job archive page.
  129. *
  130. * @since 2.2.0
  131. */
  132. do_action( 'sjb_job_listing_after' );
  133. /**
  134. * Template -> Job Listing End:
  135. *
  136. * - SJB Ending Wrapper div.
  137. */
  138. get_simple_job_board_template( 'listing/job-listings-end.php' );
  139. ?>
  140. </div>
  141. </div>
  142. <!-- ==================================================
  143. End Content Wrapper -->
  144. <div class="clearfix"></div>
  145. <?php
  146. /**
  147. * Hook -> sjb_after_main_content
  148. *
  149. * @hooked sjb_job_listing_wrapper_end - 10
  150. *
  151. * - Output Closing div of Main Container.
  152. * - Output Closing div of Content Area.
  153. *
  154. * @since 2.2.0
  155. * @since 2.2.3 Removed the content wrapper closing div
  156. */
  157. do_action('sjb_after_main_content');
  158. $html_archive = ob_get_clean();
  159. /**
  160. * Modify the Jobs Archive Page Template.
  161. *
  162. * @since 2.3.0
  163. *
  164. * @param html $html_archive Jobs Archive Page HTML.
  165. */
  166. echo apply_filters('sjb_archive_template', $html_archive);
  167. get_footer();