custom-contact.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!doctype html>
  2. <html>
  3. <?php include 'head.php'; ?>
  4. <body>
  5. <?php
  6. /*Template Name: Custom Contact*/
  7. get_header();
  8. ?>
  9. <div class="ny_ban"><img src="/wp-content/uploads/2024/03/2019072513474886.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'] ?? 38;
  19. // 输出目录
  20. echo get_slider_submenus('contact',37,$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="/contact">联系我们</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. if($cat_id != 45){
  35. // 获取该分类下的第一篇文章
  36. $args = array(
  37. 'cat' => $cat_id, // 分类ID
  38. 'posts_per_page' => 1, // 每页显示的文章数量
  39. 'orderby' => 'date', // 按日期排序
  40. 'order' => 'ASC', // 升序
  41. );
  42. $cur_post = get_posts($args);
  43. if ($cur_post) {
  44. $content = $cur_post[0]->post_content; // 文章内容
  45. echo $content;
  46. } else {
  47. echo '文章不存在';
  48. }
  49. // 释放查询结果
  50. wp_reset_postdata();
  51. }
  52. ?>
  53. <?php
  54. if($cat_id == 38){
  55. include 'map.php';
  56. }
  57. ?>
  58. <?php
  59. // 加盟申请
  60. if($cat_id == 45){
  61. include 'commentForm.php';
  62. }
  63. ?>
  64. </div>
  65. </div>
  66. </div>
  67. <style>
  68. .swiper-wrapper{height:auto;}
  69. </style>
  70. <?php get_footer(); ?>
  71. <script>
  72. jQuery(document).ready(function($) {
  73. $('#contact-form').submit(function(e) {
  74. e.preventDefault();
  75. if($("#rename").val()==''){
  76. alert('请输入姓名!');
  77. return
  78. }
  79. if($("#phone").val()==''){
  80. alert('请输入电话!');
  81. return
  82. }
  83. $.ajax({
  84. url: $(this).attr('action'),
  85. type: 'post',
  86. data: {
  87. action: 'submit_custom_comment',
  88. comment_data: $(this).serialize()
  89. },
  90. success: function(response) {
  91. alert('提交成功!');
  92. $('#contact-form')[0].reset();
  93. },
  94. error: function() {
  95. alert('提交失败,请重试.');
  96. }
  97. });
  98. });
  99. });
  100. </script>
  101. </body>
  102. </html>