custom-jobs.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!doctype html>
  2. <html>
  3. <?php include 'head.php'; ?>
  4. <body>
  5. <?php
  6. /*Template Name: Custom Jobs*/
  7. get_header();
  8. ?>
  9. <div class="ny_ban"><img src="/wp-content/uploads/2024/03/2019072513414199.jpg"></div>
  10. <div class="ny_main w1200">
  11. <div class="l">
  12. <div class="box">
  13. <div class="tit">诚聘英才</div>
  14. <div class="bor">
  15. <ul class="lm">
  16. <?php
  17. // 获取当前子分类
  18. $cat_id = $_REQUEST['fid'] ?? 40;
  19. // 输出目录
  20. echo get_slider_submenus('jobs',39,$cat_id)
  21. ?>
  22. </ul>
  23. </div>
  24. </div>
  25. <?php include 'concat.php'; ?>
  26. </div>
  27. <div class="r">
  28. <div class="tit">
  29. <div class="lj">您当前位置 :<a href="/index">首页</a> > <a href="/jobs">诚聘英才</a> > <span><?php echo get_cat_name($cat_id) ?></span></div>
  30. <span><?php echo get_cat_name($cat_id) ?></span>
  31. </div>
  32. <div class="con">
  33. <?php
  34. // 假设你已经在WordPress环境中,并且有分类ID $category_id
  35. $category_id = $cat_id; // 替换为你的分类ID
  36. // 获取分页参数
  37. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  38. // 查询参数
  39. $args = array(
  40. 'cat' => $category_id, // 分类ID
  41. 'posts_per_page' => 9, // 每页显示的文章数量
  42. 'paged' => $paged
  43. );
  44. // 查询文章
  45. $query = new WP_Query($args);
  46. if ($query->have_posts()) {
  47. if($cat_id == 40){
  48. echo '<div class="ny_jobs"><ul>';
  49. }
  50. if($cat_id == 41){
  51. echo '<div class="ny_jobs2"><ul>';
  52. }
  53. while ($query->have_posts()) {
  54. $query->the_post();
  55. // 在这里编写你的文章列表
  56. $post_id = get_the_ID(); // 获取文章ID
  57. $excerpt = get_the_excerpt(); // 获取摘要
  58. // 招聘信息
  59. if($cat_id == 40){
  60. ?>
  61. <li>
  62. <h3><?php the_title(); ?></h3>
  63. <p><?php echo $excerpt; ?></p>
  64. </li>
  65. <?php
  66. }
  67. // 员工风采
  68. if($cat_id == 41){
  69. ?>
  70. <li>
  71. <div>
  72. <?php
  73. if(has_post_thumbnail()){
  74. // 获取特色图片的ID
  75. $thumbnail_id = get_post_thumbnail_id();
  76. // 获取特色图片的URL
  77. $thumbnail_url = wp_get_attachment_url( $thumbnail_id );
  78. ?>
  79. <a href="#"><img src="<?php echo $thumbnail_url ?>" width="100%"></a>
  80. <?php
  81. }
  82. ?>
  83. </div>
  84. <h3><a href="#"><?php the_title(); ?></a></h3>
  85. </li>
  86. <?php
  87. }
  88. }
  89. echo '</ul></div>';
  90. // 分页导航
  91. lingfeng_pagenavi();
  92. } else {
  93. // 没有找到文章的提示
  94. echo '没有找到文章。';
  95. }
  96. // 重置WordPress查询
  97. wp_reset_postdata();
  98. ?>
  99. </div>
  100. </div>
  101. </div>
  102. <style>
  103. .swiper-wrapper{height:auto;}
  104. </style>
  105. <?php get_footer(); ?>
  106. </body>
  107. </html>