custom-join.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <!doctype html>
  2. <html>
  3. <?php include 'head.php'; ?>
  4. <body>
  5. <?php
  6. /*Template Name: Custom Join*/
  7. get_header();
  8. ?>
  9. <div class="ny_ban"><img src="/wp-content/uploads/2024/03/2019072513554171.png"></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. <li><a href="/joinIndex"><span>&gt;&gt;</span>加盟首页</a></li>
  17. <?php
  18. // 获取当前子分类
  19. $cat_id = $_REQUEST['fid'] ?? 12;
  20. // 输出目录
  21. echo get_slider_submenus('join',10,$cat_id)
  22. ?>
  23. </ul>
  24. </div>
  25. </div>
  26. <?php include 'concat.php'; ?>
  27. </div>
  28. <div class="r">
  29. <div class="tit">
  30. <div class="lj">您当前位置 :<a href="/index">首页</a> > <a href="/join">我要加盟</a> > <span><?php echo get_cat_name($cat_id) ?></span></div>
  31. <span><?php echo get_cat_name($cat_id) ?></span>
  32. </div>
  33. <div class="con <?php echo $cat_id == 13 ? 'jmtj':'' ?>">
  34. <?php
  35. if($cat_id != 16 && $cat_id != 17){
  36. // 获取该分类下的第一篇文章
  37. $args = array(
  38. 'cat' => $cat_id, // 分类ID
  39. 'posts_per_page' => 1, // 每页显示的文章数量
  40. 'orderby' => 'date', // 按日期排序
  41. 'order' => 'ASC', // 升序
  42. );
  43. $cur_post = get_posts($args);
  44. setup_postdata($cur_post);
  45. if (count($cur_post)>0) {
  46. $content = $cur_post[0]->post_content; // 文章内容
  47. echo $content;
  48. } else {
  49. echo '文章不存在';
  50. }
  51. // 释放查询结果
  52. wp_reset_postdata();
  53. }
  54. // 加盟解答
  55. if($cat_id == 16){
  56. // 假设你已经在WordPress环境中,并且有分类ID $category_id
  57. $category_id = $cat_id; // 替换为你的分类ID
  58. // 获取分页参数
  59. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  60. // 查询参数
  61. $args = array(
  62. 'cat' => $category_id, // 分类ID
  63. 'posts_per_page' => 10, // 每页显示的文章数量
  64. 'paged' => $paged
  65. );
  66. // 查询文章
  67. $query = new WP_Query($args);
  68. $index = 0 + ($paged-1) * 10;
  69. echo '<div class="ny_join6">';
  70. if ($query->have_posts()) {
  71. while ($query->have_posts()) {
  72. $query->the_post();
  73. // 在这里编写你的文章列表
  74. $post_id = get_the_ID(); // 获取文章ID
  75. $index = $index + 1;
  76. $content = get_post_field('post_content', $post_id);
  77. ?>
  78. <dl>
  79. <dt><div></div><span><?php echo $index ?></span><?php the_title(); ?></dt>
  80. <dd><?php echo $content ?></dd>
  81. </dl>
  82. <?php
  83. }
  84. // 分页导航
  85. lingfeng_pagenavi();
  86. } else {
  87. // 没有找到文章的提示
  88. echo '没有找到文章。';
  89. }
  90. echo '</div>';
  91. }
  92. // 加盟申请
  93. if($cat_id == 17){
  94. include 'commentForm.php';
  95. }
  96. ?>
  97. </div>
  98. </div>
  99. </div>
  100. <style>
  101. .swiper-wrapper{height:auto;}
  102. </style>
  103. <?php get_footer(); ?>
  104. <script>
  105. jQuery(document).ready(function($) {
  106. $('.ny_join6 dl dt').click(function(){
  107. var a=$(this).parent('dl').attr('class');
  108. if(a=='on'){
  109. $(this).parent('dl').removeClass('on');
  110. }else{
  111. $(this).parent('dl').addClass('on').siblings().removeClass('on');
  112. }
  113. });
  114. $('#contact-form').submit(function(e) {
  115. e.preventDefault();
  116. if($("#rename").val()==''){
  117. alert('请输入姓名!');
  118. return
  119. }
  120. if($("#phone").val()==''){
  121. alert('请输入电话!');
  122. return
  123. }
  124. $.ajax({
  125. url: $(this).attr('action'),
  126. type: 'post',
  127. data: {
  128. action: 'submit_custom_comment',
  129. comment_data: $(this).serialize()
  130. },
  131. success: function(response) {
  132. alert('提交成功!');
  133. $('#contact-form')[0].reset();
  134. },
  135. error: function() {
  136. alert('提交失败,请重试.');
  137. }
  138. });
  139. });
  140. });
  141. </script>
  142. </body>
  143. </html>