Advertisement
ikamal7

query

Sep 27th, 2020
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.52 KB | None | 0 0
  1.  
  2. /*
  3. if ( !empty( $type ) ) {
  4. if (!in_array('all', $type) ) {
  5. $args['tax_query'] = array(
  6. array(
  7. 'taxonomy' => 'job-type',
  8. 'field'    => 'slug',
  9. 'terms'    => $type,
  10. ),
  11. );
  12. } else {
  13. $term_id = [];
  14. $_terms  = get_terms( ['taxonomy' => 'job-type', 'hide_empty' => true] );
  15. foreach ( $_terms as $_term ) {
  16. $term_id[] = $_term->term_id;
  17. }
  18.  
  19. $args['tax_query'] = array(
  20. array(
  21. 'taxonomy' => 'job-type',
  22. 'field'    => 'term_id',
  23. 'terms'    => $term_id,
  24. ),
  25. );
  26. }
  27. }
  28.  
  29. if ( !empty( $industry ) ) {
  30. if ( !in_array('all', $industry )) {
  31. $args['tax_query'] = array(
  32. array(
  33. 'taxonomy' => 'industry',
  34. 'field'    => 'slug',
  35. 'terms'    => $industry,
  36. ),
  37. );
  38. } else {
  39. $term_id = [];
  40. $_terms  = get_terms( ['taxonomy' => 'industry', 'hide_empty' => true] );
  41. foreach ( $_terms as $_term ) {
  42. $term_id[] = $_term->term_id;
  43. }
  44. $args['tax_query'] = array(
  45. array(
  46. 'taxonomy' => 'industry',
  47. 'field'    => 'term_id',
  48. 'terms'    => $term_id,
  49. ),
  50. );
  51. }
  52. }
  53.  
  54. if ( !empty( $location ) ) {
  55. if ( !in_array('all', $location ) ) {
  56. $args['tax_query'] = array(
  57. array(
  58. 'taxonomy' => 'job-location',
  59. 'field'    => 'slug',
  60. 'terms'    => $location,
  61. ),
  62. );
  63. } else {
  64. $term_id = [];
  65. $_terms  = get_terms( ['taxonomy' => 'job-location', 'hide_empty' => true] );
  66. foreach ( $_terms as $_term ) {
  67. $term_id[] = $_term->term_id;
  68. }
  69. $args['tax_query'] = array(
  70. array(
  71. 'taxonomy' => 'job-location',
  72. 'field'    => 'term_id',
  73. 'terms'    => $term_id,
  74. ),
  75. );
  76. }
  77. }
  78.  
  79. if ( !empty( $role ) ) {
  80. if (!in_array('all', $role ) ) {
  81. $args['tax_query'] = array(
  82. array(
  83. 'taxonomy' => 'job-speciality',
  84. 'field'    => 'slug',
  85. 'terms'    => $role,
  86. ),
  87. );
  88. } else {
  89. $term_id = [];
  90. $_terms  = get_terms( ['taxonomy' => 'job-speciality', 'hide_empty' => true] );
  91. foreach ( $_terms as $_term ) {
  92. $term_id[] = $_term->term_id;
  93. }
  94. $args['tax_query'] = array(
  95. array(
  96. 'taxonomy' => 'job-speciality',
  97. 'field'    => 'term_id',
  98. 'terms'    => $term_id,
  99. ),
  100. );
  101. }
  102. }
  103.  
  104. if ( !empty( $ql ) ) {
  105. if ( !in_array('all', $ql ) ) {
  106. $args['meta_query'] = array(
  107. array(
  108. 'key'     => 'qualification',
  109. 'value'   => $ql,
  110. 'compare' => 'IN',
  111. ),
  112. );
  113. } else {
  114. $args['meta_query'] = array(
  115. array(
  116. 'key'     => 'qualification',
  117. 'compare' => 'EXISTS',
  118. ),
  119. );
  120. }
  121. }
  122.  
  123. if ( !empty( $experience ) ) {
  124. if ( !in_array('all', $experience ) ) {
  125. $args['meta_query'] = array(
  126. array(
  127. 'key'     => 'experience',
  128. 'value'   => strval( $experience ),
  129. 'compare' => 'IN',
  130. ),
  131. );
  132. } else {
  133. $args['meta_query'] = array(
  134. array(
  135. 'key'     => 'experience',
  136. 'compare' => 'EXISTS',
  137. ),
  138. );
  139. }
  140. }
  141.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement