WordPress functions.php 攻略:这些实用技巧让你少走三年弯路

在 WordPress 主题里,有一个文件被很多老站长称为“瑞士军刀”——那就是 functions.php。它不像页面那样能被直接看到,却几乎能控制网站的一切:从添加一段简单的代码,到彻底改变后台行为、优化 SEO、甚至打造自定义功能。但正因为它的威力巨大,稍有不慎,整个网站就会白屏崩溃。本文将给你一份既实用又安全的 functions.php 技巧清单,以及新手最容易踩的 3 个大坑。

functions.php 到底是什么?

简单说,它是当前主题的“功能驱动引擎”。WordPress 在每次加载页面时都会自动执行这个文件里的代码。你可以在这里添加自定义函数、钩子(Hook)、短代码(Shortcode)、移除默认行为……几乎所有“主题层面”的定制都能通过它完成。但请记住:它属于主题,而不是 WordPress 核心或插件。换主题后,这些功能会消失。

第一部分:高频实用代码片段(直接复制可用)

以下代码均经过实测,添加到你的(子主题)functions.php 末尾即可生效。注意:不要加 标签套嵌,只需在已有 之后继续追加。

1. 在页脚添加自定义前端代码(如统计、客服代码)

// 在页脚添加自定义代码 add_action('wp_footer', function() {     echo '';     echo ''; });

场景:添加百度统计、Google Analytics、LiveChat、第三方验证等。不用修改主题文件,升级主题不会丢失。

2. 禁止后台所有更新提示(让后台变干净)

// 禁止核心、插件、主题更新通知(仅对非管理员有效,可选) add_action('admin_init', function() {     remove_action('admin_notices', 'update_nag', 3);     add_filter('pre_site_transient_update_core', '__return_null');     add_filter('pre_site_transient_update_plugins', '__return_null');     add_filter('pre_site_transient_update_themes', '__return_null'); });

注意:这会让后台完全看不到任何更新提醒。如果你需要定期手动更新,建议只对“非管理员”隐藏,或者用更温和的方式。

3. 为全站没有 alt 属性的图片自动添加 alt 标签(提升 SEO)

// 自动为缺失 alt 的 img 添加基于图片文件名或文章标题的 alt add_filter('wp_get_attachment_image_attributes', function($attr, $attachment) {     if (empty($attr['alt'])) {         $attr['alt'] = !empty($attachment->post_title)              ? trim(strip_tags($attachment->post_title))              : basename(get_attached_file($attachment->ID));     }     return $attr; }, 10, 2);

效果:Google 抓取时会看到有意义的 alt 文本,避免因缺失 alt 被判定为低质量图片页面。对已有旧文章尤其友好。

4. 定义一个网站专属短代码 [year] 显示当前年份(版权信息专用)

// 短代码 [year] 自动输出当前年份 add_shortcode('year', function() {     return date('Y'); });

用法:在文章或页面编辑器中输入 [year],显示 2026(动态更新)。适合页脚版权声明:“© 2015-[year] 你的网站”。不需要每年手动改。

5. 移除 WordPress 版本号(安全瘦身)

// 移除 head 中的 WordPress 版本号 remove_action('wp_head', 'wp_generator');

6. 禁用 XML-RPC(减少暴力破解攻击)

// 完全禁用 XML-RPC add_filter('xmlrpc_enabled', '__return_false'); remove_action('wp_head', 'rsd_link');

7. 更改后台登录错误提示(防止用户名暴露)

// 登录错误时统一提示,不告知是用户名错还是密码错 add_filter('login_errors', function() {     return '用户名或密码错误,请重试。'; });

第二部分:functions.php 进阶技巧(让网站脱胎换骨)

8. 自动为文章标题添加 SEO 前缀(无需插件)

// 自动修改文章页  标签格式:文章标题 - 网站名 add_filter('pre_get_document_title', function($title) {     if (is_single() || is_page()) {         $post_title = get_the_title();         $site_name = get_bloginfo('name');         return $post_title . ' - ' . $site_name;     }     return $title; });</code></pre>
<h4>9. 批量替换文章中的特定文本(比如旧域名、错误链接)</h4>
<pre><code>// 替换文章内容中的字符串(不操作数据库,只在输出时替换) add_filter('the_content', function($content) {     $old = 'http://旧域名.com';     $new = 'https://新域名.com';     return str_replace($old, $new, $content); }, 20);</code></pre>
<h4>10. 禁用 Gutenberg 编辑器,恢复经典编辑器(适合不习惯新编辑器的用户)</h4>
<pre><code>// 禁用块编辑器,使用经典编辑器 add_filter('use_block_editor_for_post', '__return_false', 10); add_filter('use_block_editor_for_post_type', '__return_false', 10);</code></pre>
<h3>第三部分:避坑指南 —— 这 3 个错误会让你的网站直接白屏</h3>
<p>functions.php 虽然强大,但它的错误极其致命:因为它在 WordPress 核心加载后立即执行,任何语法错误都会导致整个网站(包括后台)无法访问,也就是“白屏死亡”。</p>
<h4>❌ 误区一:直接在父主题修改 functions.php</h4>
<p><strong>问题</strong>:当父主题更新时,你添加的所有代码都会被覆盖丢失。<br />
<strong>正确做法</strong>:创建<strong>子主题(Child Theme)</strong>,在子主题的 functions.php 中添加代码。这样即使父主题升级,你的功能依然安全。<br />
<strong>如何快速创建子主题</strong>:在 <code>/wp-content/themes/</code> 下新建文件夹,如 <code>my-child-theme</code>,里面放两个文件:</p>
<ul>
    <li><code>style.css</code>(注明 Template: 父主题文件夹名)</li>
    <li><code>functions.php</code>(开头加 <code><?php</code> 即可)<br />
    然后在后台启用子主题。已有代码不会丢失。</li>
</ul>
<h4>❌ 误区二:代码中有一个多余的空格或分号,导致白屏</h4>
<p><strong>典型错误</strong>:函数名写错、少写 <code>;</code>、多写 <code>}</code>、或者直接在 <code><?php</code> 之前有空字符。<br />
<strong>急救方法</strong>:</p>
<ul>
    <li>通过 FTP 或 VPS 终端连接服务器,进入 <code>/wp-content/themes/你的主题/</code>,把 <code>functions.php</code> 下载下来,用代码编辑器(VS Code、Notepad++)检查语法错误。</li>
    <li>如果没有错误提示,暂时把整个文件内容备份后清空,只留 <code><?php</code> 保存,网站就能恢复。然后逐段加回代码排查。</li>
    <li><strong>终极建议</strong>:永远在本地测试环境(XAMPP/WAMP 或 Local WP)先测试 functions.php 代码,再上线。</li>
</ul>
<h4>❌ 误区三:功能堆积上千行,难以维护</h4>
<p><strong>问题</strong>:很多人把 functions.php 当成垃圾场,所有代码都塞进去。几个月后根本不敢动,因为一动就不知道哪里会出错。<br />
<strong>最佳实践</strong>:</p>
<ul>
    <li>按功能分组,加注释:<code>// ========== SEO 优化 ==========</code></li>
    <li>把不同功能的代码拆分到单独的文件(例如 <code>inc/seo.php</code>,<code>inc/custom-shortcodes.php</code>),然后在 functions.php 中用 <code>require_once __DIR__ . '/inc/seo.php';</code> 引入。</li>
    <li>只放“必须属于主题”的功能。通用功能(如自定义文章类型、表单)建议做成插件,换主题也不会丢失。</li>
</ul>
<h3>第四部分:一个稳妥的 functions.php 结构模板(可直接套用)</h3>
<pre><code><?php /**  * 子主题/父主题 functions.php 安全结构  * 作者:你的名字  */  // 防止直接访问 if (!defined('ABSPATH')) {     exit; }  // 1. 基本配置 define('THEME_VERSION', '1.0.0');  // 2. 引入功能模块(推荐) require_once get_template_directory() . '/inc/customizer.php'; require_once get_stylesheet_directory() . '/inc/cleanup.php';   // 子主题用 get_stylesheet_directory  // 3. 移除默认功能 remove_action('wp_head', 'wp_generator');  // 4. 添加自定义功能(按类别排列) // ========== SEO 相关 ========== add_filter('pre_get_document_title', 'my_custom_title'); function my_custom_title($title) {     // 代码     return $title; }  // ========== 性能优化 ========== add_action('wp_enqueue_scripts', 'my_dequeue_scripts'); function my_dequeue_scripts() {     // 移除不需要的 CSS/JS }  // ========== 短代码 ========== add_shortcode('year', 'my_year_shortcode'); function my_year_shortcode() {     return date('Y'); }  // 文件末尾无需加 ?>,避免意外空格</code></pre>
<h3>最后一条建议:永远备份再修改</h3>
<p>修改 functions.php 之前,先通过 FTP 或主题编辑器下载一份原文件。如果改完白屏,马上用备份覆盖。另外,强烈推荐安装一个“代码片段管理插件”(如 Code Snippets),它可以把 functions.php 中的功能单独管理、开关、甚至导入导出,而且不会因为语法错误让网站崩溃。当你彻底理解 functions.php 后,你会发现 WordPress 的灵活度几乎无限。</p>
<p>现在,去给你的网站加一个实用的短代码,或者清理掉那些冗余的后台提示吧。</p>            </div>
            <!--上下篇-->
            <div class="page-nav">
                                <p>上一篇:<a href="/hangye/5011">WordPress 慢如蜗牛?这份提速清单,让网站速度飙升到 90+ 分!</a></p>
                                <p>下一篇:<a href="/hangye/5013">选择 GPU 服务器租用还是购买?成本与长期成本的决策指南</a></p>
                                <div class="back-btn">
                    <a href="https://www.idcbest.hk/hangye/">【返回】</a>
                </div>
            </div>
        </div>
    </div>


<!-----侧边开始-------->
    <style>
      html{ font-family: tahoma,"HanHei SC","Microsoft YaHei",Arial,helvetica,sans-serif;}
    body,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,legend,input,button,textarea,select,p,blockquote,th,td {margin: 0;padding: 0}
    li{list-style: none;}
    .clear{*zoom:1}
    .clear:after {clear: both;height: 0;overflow: hidden;display: block;visibility: hidden;content: "."}
    a{text-decoration: none; cursor: pointer}
         a:hover {text-decoration: none}
.qq_con{position: fixed;top: 200px;right: 5px;z-index: 9999;}
.qq_list{float: right}
.qq_list>li{width: 50px;height: 50px;box-sizing: border-box;background: #2a88e0 url("/images/qq_icon1.png") no-repeat 0px 0px;cursor: pointer;margin-top: 8px;}
.qq_list>li:nth-child(3) {background:#fff  url("/images/qq_icon1.png") no-repeat 0px -58px;}
.qq_list>li:nth-child(2) {background:#fff  url("/images/qq_icon1.png") no-repeat 0px -117px;}
.qq_list>li:nth-child(4) {background:#fff  url("/images/qq_icon1.png") no-repeat 0px -175px;}
.qq_list>li:nth-child(5) {background:#fff  url("/images/qq_icon1.png") no-repeat 0px -233px;}
.qq_list>li:hover{background-position-x: -60px}
.qq_list>li:hover .qq_list_con{display: block}
.qq_list_con{float: right;}
.qq_list_con{display: none;position: absolute;right: 50px;box-sizing: border-box;padding-right: 23px}
.qq_list>li:nth-child(2) .qq_list_con{top:-30%}
.qq_list_cons{box-sizing: border-box;padding: 30px;border-top: 3px solid #0084ff;border-right: 1px solid #dddddd;border-bottom:1px solid #dddddd;border-left: 1px solid #dddddd; background:#fff}
.qq_list_con1{width: 251px;}
.qq_top{width: 100%;box-sizing: border-box;padding-bottom: 15px;border-bottom: 1px solid #eee}
.qq_top>img{float: left;margin-right: 15px;width: 25px;height: 25px;}
.qq_top>.qq_tit{float: left;}
.qq_top>.qq_tit>p:nth-child(1){font-size: 20px;color: #0084ff;margin-top: -2px;}
.qq_top>.qq_tit>p:nth-child(2){font-size: 20px;color: #666;margin-top: 12px}
.qq_btm{box-sizing: border-box;padding-top: 14px}
.qq_btmTit{font-size: 14px;color: #333}

.qq_btm_kf>a{display: inline-block;width: 100%;height: 29px;line-height: 29px;font-size: 20px;color: #0084ff;margin-right: 30px;vertical-align: middle;}
.qq_btm_kf>a>span{font-size: 14px;color: #999999;display: block;}
.qq_btm_kf>a:last-child{margin-right: 0}
.qq_btm_kf>a:hover{color: #0084ff}
.qq_btm_kf>a>img{vertical-align: middle;margin-right: 7px;margin-top: -7px;}
.qq_list_con2{width: 272px;}
.qq_phone{font-size: 24px;color: #0084ff;text-align: center}
.qq_phone2{font-size: 14px;color: #999999;margin-top: 12px;text-align: center}
.qq_list_con3{width: 350px;}
.qq_ewm{width: 120px;float: left;text-align: center}
.qq_ewm>span{font-size: 12px;color: #0084ff;}
.qq_list_con4{width: 400px;height: 266px;border: none;padding: 0;margin-top: -60px}

.qq-kf{box-sizing: border-box;width: 300px;display: flex;flex-wrap: wrap;}
.qq-kfList{margin-top: 20px;width: 140px;cursor: pointer;}
.qq-kf>.qq-kfList:nth-child(2n){margin-left: 20px;}
.qq-kfList>.qq-kfName>img{margin-right: 6px;vertical-align: middle;display: inline-block;}
.qq-kfList>.qq-kfName>span{font-size: 14px;color: #666}
.qq-kfList>.qq-kfName>span.qq-kfNameAct{color: #1b7edc}
.qq-kfEwm{display: none;width:300px;background: #fff;box-shadow: 0 0 18px rgba(0,0,0,0.08);margin-top: 16px;box-sizing: border-box;padding: 20px 30px;position: relative}
.qq-kf>.qq-kfList:nth-child(2n) .qq-kfEwm{margin-left: -160px}
.qq-kfEwm>.cbqq-sj{position: absolute;top:-10px;left: 36px;}
.qq-kf>.qq-kfList:nth-child(2n) .cbqq-sj{position: absolute;top:-10px;left: 197px;}
.qq-kfEwm>.qq-kfzx{float: left;width: 102px;margin-right: 35px;}
.qq-kfEwm>.qq-kfzx:last-child{margin-right: 0}
.qq-kfEwm>.qq-kfzx>p{width: 102px;height: 102px;border: 1px solid #ededed;text-align: center;}
.qq-kfEwm>.qq-kfzx1>p{border: 2px solid #2bc200;}
.qq-kfEwm>.qq-kfzx>p>img{margin-top: 7px;display: inline-block;}
.qq-kfEwm>.qq-kfzx>a{display: block;width: 102px;height: 32px;background: #1b7edc;font-size: 14px;color: #fff;text-align: center;line-height: 32px;border-radius: 8px;margin-top: 15px;}
.qq-kfList>.qq-kfName{position: relative}
.qq-kfList>.qq-kfName>.cbwz-hd{position: absolute;top: -3px;left: 13px;animation: blink 1s infinite}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.qq_phone>img{margin-top: -3px;margin-right: 8px;display: inline-block;}
    </style>
</head>
<body>


<div class="qq_con clear">
    <ul class="qq_list">
        <li onClick="window.open('https://url.cn/HNvbrciI?_type=wpa&qidian=true')">
            <div class="qq_list_con">
               <div class="qq_list_cons qq_list_con1">
                  <div class="qq_btm" style="padding-top:0px">
                        <p class="qq_phone" onClick="window.open('https://url.cn/HNvbrciI?_type=wpa&qidian=true')"><img src="/images/qyqq.png" >企业QQ咨询</p>
                        <p class="qq_phone2">7*24小时售前咨询</p>
                  </div>
                </div>
            </div>
        </li>
        <li> <div class="qq_list_con">
                <div class="qq_list_cons qq_list_con3"> <div class="qq_top clear">
                        <img src="/images/qq_icon5.png" alt="">
                        <div class="qq_tit">
                            <p>客服咨询</p>
                        </div>
                    </div>
                    <ul class="qq-kf clear">
                <ul class="qq-kf clear">
                     <li class="qq-kfList">
                            <p class="qq-kfName">
                                <img src="/images/cbwx.png" alt="">
                                <img src="/images/cbqq.png" alt="">
                                <span class="qq-kfNames">天下数据21</span>
                            </p>
                            <div class="qq-kfEwm clear" >
                                <img src="/images/cbqq-sj.png" alt="" class="cbqq-sj">
                                <div class="qq-kfzx qq-kfzx1">
                                    <p>
                                        <img src="/images/lizheng-wx.png" alt="">
                                    </p>
                                    <a href="#">微信咨询</a>
                                </div>
                                <div class="qq-kfzx">
                                    <p>
                                        <img src="/images/lizheng-qq.png" alt="">
                                    </p>
                                    <a href="#">QQ咨询</a>
                                </div>
                            </div>
                        </li>   
                     
                      <li class="qq-kfList"> <p class="qq-kfName">
                                <img src="/images/cbwx.png" alt="">
                                <img src="/images/cbqq.png" alt="">
                                <span class="qq-kfNames">天下数据03</span>
                                <img src="/images/cbwz-hd.png" alt="" class="cbwz-hd">
                            </p>
                            <div class="qq-kfEwm clear"> <img src="/images/cbqq-sj.png" alt="" class="cbqq-sj">
                                <div class="qq-kfzx qq-kfzx1">
                                    <p><img src="/images/zyb-wx.png" alt=""></p>
                                    <a href="#">微信咨询</a>
                                </div>
                                <div class="qq-kfzx">
                                    <p><img src="/images/zyb-qq.png" alt=""></p>
                                    <a href="#">QQ咨询</a>
                                </div>
                            </div>
                        </li>
                   
                        <li class="qq-kfList"> <p class="qq-kfName">
                                <img src="/images/cbwx.png" alt="">
                                <img src="/images/cbqq.png" alt="">
                                <span class="qq-kfNames">天下数据16</span>
                                <img src="/images/cbwz-hd.png" alt="" class="cbwz-hd">
                            </p>
                            <div class="qq-kfEwm clear" >
                                <img src="/images/cbqq-sj.png" alt="" class="cbqq-sj">
                                <div class="qq-kfzx qq-kfzx1" style="display: block">
                                    <p><img src="/images/wjj-wx.png" alt=""></p>
                                    <a href="#">微信咨询</a>
                                </div>
                                <div class="qq-kfzx">
                                    <p><img src="/images/wjj-qq.png" alt=""></p>
                                    <a href="#">QQ咨询</a>
                                </div>
                            </div>
                        </li>    
                    </ul> 
                </div>
            </div>
        </li>
         <li>
            <div class="qq_list_con">
                <div class="qq_list_cons qq_list_con2">
                    <div class="qq_top clear">
                        <img src="/images/qq_icon4.png" alt="服务热线">
                        <div class="qq_tit">
                            <p>服务热线</p>
                        </div>
                    </div>
                    <div class="qq_btm">
                        <p class="qq_phone" onClick="window.open('tel:4006388808')">400-638-8808</p>
                        <p class="qq_phone2">7*24小时客服服务热线</p>
                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="qq_list_con">
                <div class="qq_list_cons qq_list_con4">
                    <img src="https://www.idcbest.hk/images/cuxiao-400-hk.jpg" alt="最新活动" width="400" height="266"  onclick="window.open('https://www.idcbest.hk/cuxiao.html')">
                </div>
            </div>
        </li>
        <li id="back-top"><a href="javascript:;"></a></li>
    </ul>
</div>

<script type="text/javascript" src="/js/jquery.min.js"></script> 
<script type="text/javascript">
$(function() { 
  $('#back-top').hide();
  $(window).scroll(function() {
    if ($(window).scrollTop() > 50) {
      $('#back-top').fadeIn(1000);
    } else {
      $("#back-top").fadeOut(1000);
    }
  });
  $("#back-top").click(function() {
    $('body,html').animate({
      scrollTop: '0'
    }, 1000);
    return false;
  });

  // --- NEW QQ HOVER LOGIC ---
  const $kfListContainer = $(".qq_list_cons.qq_list_con3");
  if ($kfListContainer['length'] > 0) { // Ensure the container exists
    const $kfItems = $kfListContainer['find'](".qq-kf > .qq-kfList");

    const $item18Div = $kfItems['eq'](0); // "天下数据18"
    const $item03Div = $kfItems['eq'](1); // "天下数据03"
    const $item16Div = $kfItems['eq'](2); // "天下数据16"
    const $item15Div = $kfItems['eq'](3); // "天下数据15"

    // Helper function to set the visibility and active class
    function setKfItemsState(visibleItemIndices) {
        $kfItems['each'](function(index) {
            const $this = $(this);
            const $ewm = $this['find'](".qq-kfEwm");
            const $nameSpan = $this['find'](".qq-kfNames");

            if (visibleItemIndices.includes(index)) {
                $ewm['css']('display', 'block');
                $nameSpan['addClass']("qq-kfNameAct");
            } else {
                $ewm['css']('display', 'none');
                $nameSpan['removeClass']("qq-kfNameAct");
            }
        });
    }

    // Default state: "天下数据03" (index 1) and "天下数据15" (index 3) expanded
    function applyDefaultState() {
        setKfItemsState([1, 3]);
    }

    // State for hovering "天下数据18" div: "天下数据18" (index 0) and "天下数据15" (index 3) expanded
    function applyStateHover18() {
        setKfItemsState([0, 3]);
    }

    // State for hovering "天下数据16" div: "天下数据03" (index 1) and "天下数据16" (index 2) expanded
    function applyStateHover16() {
        setKfItemsState([1, 2]);
    }

    // Initial state on page load
    applyDefaultState();

    // Event Handlers for specific items
    $item18Div['on']('mouseenter.qqHover', function() {
        applyStateHover18();
    });
    $item16Div['on']('mouseenter.qqHover', function() {
        applyStateHover16();
    });
    $item03Div['on']('mouseenter.qqHover', function() {
        applyDefaultState();
    });
    $item15Div['on']('mouseenter.qqHover', function() {
        applyDefaultState();
    });

    // Handle hover over the main container "qq_list_con3" for general areas
    $kfListContainer['on']('mouseenter.qqHover', function(event) {
        const $target = $(event.target);
        // Check if the mouse is over a specific kfList item or its children
        const $closestKfList = $target['closest']('.qq-kfList', this);

        if ($closestKfList['length'] === 0) {
            // Mouse is NOT over a specific qq-kfList item (e.g., on padding, qq_top)
            applyDefaultState();
        }
        // If mouse is over a kfList item, its specific handler will manage the state.
    });

    // Handle mouse leaving the main "客服咨询" li (the one that shows/hides qq_list_con3)
    // This ensures that when the panel is re-shown, it's in the default state.
    const $customerServiceLi = $(".qq_list > li").has($kfListContainer);
     // More specific selector: const $customerServiceLi = $(".qq_list > li:nth-child(2)");
    if ($customerServiceLi['length'] > 0) {
        $customerServiceLi['on']('mouseleave.qqReset', function() {
            applyDefaultState();
        });
    }
  }
  // --- END OF NEW QQ HOVER LOGIC ---

  // Original hover logic to be removed/commented:
  /*
  $(".qq-kf>.qq-kfList").hover(function (){
      var $Index=$(this).index();
      $(".qq-kfEwm").eq($Index).show().parent().siblings().find(".qq-kfEwm").hide();
      $('.qq-kf>.qq-kfList').eq($Index).find('.qq-kfName').find('.qq-kfNames').addClass('qq-kfNameAct').parent('.qq-kfName').parent('.qq-kf>.qq-kfList').siblings().find('.qq-kfName').find('.qq-kfNames').removeClass('qq-kfNameAct');
  })
  */
});
</script>


<script id="qd30090730658ff2b9512d5cf4a2f91fdc76b447228f" data-agl-cvt="32" src="https://wp.qiye.qq.com/qidian/3009073065/8ff2b9512d5cf4a2f91fdc76b447228f" charset="utf-8" async defer></script>

<!-- 谷歌 start -->
<!-- Global site tag (gtag.js) - Google Ads: 10948289161 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-10948289161"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-10948289161');
</script>
<!-- Event snippet for idcbest.hk/ -- 注册 conversion page -->
<script>
gtag('event', 'conversion', {'send_to': 'AW-10948289161/t0a2CJGgh88DEInFxuQo'});
</script>
<!-- 谷歌 start --><!--侧边  -->
<!-----底部开始-------->


<style>

 :root {
      --primary-color: #0066ff;
      --secondary-color: #333;
      --accent-color: #FF7800;
      --light-color: #f8f9fa;
      --dark-color: #212529;
      --gray-color: #f5f5f6;
      --border-color: #eee;   /* 边框颜色 */
      --bg-color: #fff;      /* 深色背景 */
      --hover-color: #4facfe;    /* 渐变蓝 */
      --text-color: #1d2129;    /* 浅色文字 */
      --highlight-color: #00d2ff; /* 高亮颜色 */
      --card-bg: #1a1a2e;       /* 卡片背景 */
      --white: #ffffff;
      --gray-100: #f8f9fa;
      --gray-200: #e9ecef;
      --gray-300: #dee2e6;
      --gray-400: #ced4da;
      --gray-500: #adb5bd;
      --gray-600: #6c757d;
      --gray-700: #495057;
      --shadow: 0 4px 12px rgba(0,0,0,0.05);
      --transition: all 0.3s ease;
    }

    /*导航*/

    body {
      font-family: pingfang SC,helvetica neue,arial,hiragino sans gb,microsoft yahei ui,microsoft yahei,simsun,sans-serif!important;
      background-color: var(--bg-color);
      color: var(--text-color);
    }
    .h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6{font-weight: 600}

     /* 页脚 */
    .footer {
      background: #f5f7fa;
      color: #666;
      padding: 60px 0 20px;
    }

    .footer-txt{font-size: 14px;}

    .footer-links { width:100%; }

    .footer-links h5 {
      font-weight: 600;
      margin-bottom: 20px;
      color: #333;
      font-size: 18px;
      position: relative;
      cursor: pointer;
      padding-right: 25px;
    }

    .footer-links h5 .toggle-icon {
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      transition: var(--transition);
    }

    .footer-links h5 .toggle-icon.rotated {
      transform: translateY(-50%) rotate(180deg);
    }

    .footer-links ul {
      list-style: none;
      padding: 0;
      transition: var(--transition);
    }

    .footer-links li {
      margin-bottom: 12px;
    }

    .footer-links a {
      color: #666;
      transition: all 0.2s ease;
      text-decoration: none;
      font-size: 14px;
    }

    .footer-links a:hover {
      color: var(--primary-color);
    }

    .copyright {
      border-top: 1px solid #eee;
      padding-top: 20px;
      margin-top: 40px;
      color: #999;
      font-size: 14px;
    }
    .footer-Logo{width: 120px}

    /* 移动端(目标样式:白色卡片,均匀分布,标题+箭头居中) */
    @media (max-width: 991.98px) {

      /* 让每个含 col-md-6 的列成为视觉上的“卡片” */
      .footer .row > div[class*="col-md-6"] {
        padding: 0;              /* 内部由 footer-links 控制 */
        margin: 0px;
        overflow: hidden;
      }

      /* 让 footer-links 占满卡片宽度,并去掉额外内边距 */
      .footer-links {
        padding: 0;
        width: 100%;
      }

      /* 标题区域:固定高度,水平+垂直居中(标题和箭头作为一组) */
      .footer-links h5 {
        height: 66px;                /* 固定高度,使每块高度一致 */
        margin: 0;                   /* 去掉原本的下外边距 */
        display: flex;
        align-items: center;         /* 垂直居中 */
        justify-content: space-between;
        padding: 0 16px;
        border-bottom: 1px solid #ddd;
        font-size: 16px;
        color: #666;
        background: transparent;
        font-weight: normal;
      }

      /* 箭头不再绝对定位,跟随标题文本在右侧显示小间距 */
      .footer-links h5 .toggle-icon {
        position: static;
        transform: none;
        margin-left: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
      }

      .footer-links h5 .toggle-icon.rotated {
        transform: rotate(180deg);
      }

      /* 折叠内容内边距 */
      .footer-links .collapse {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.28s ease;
      }

      .footer-links .collapse.show {
        max-height: 800px; /* 展开时允许足够高度 */
        background: #fff;   /* 浅灰色背景 */
      }

      .footer-links ul {
        padding: 12px 16px;
        margin: 0;
      }
      .copyright{
        border-top: none;
        margin-top: 20px;
      }
    }

    /* 桌面端仍保持原来行为(全部展开,隐藏箭头) */
    @media (min-width: 992px) {
      .collapse {
        display: block !important;
        max-height: none !important;
      }

      .footer-links h5 .toggle-icon {
        display: none;
      }

      .footer-links h5 {
        cursor: auto;
        padding-right: 0;
      }

      /* 恢复行间距 */
      .footer .row > div[class*="col-md-6"] {
        background: transparent;
        box-shadow: none;
        padding: 0;
        margin-bottom: 0;
        border-radius: 0;
      }
    }
 /* 二维码工具提示 */
    .qr-tooltip {
      position: relative;
      display: inline-block;
      margin-right: 15px;
      background: #fff;
      width: 36px;
      height: 36px;
      border-radius: 50%;
      text-align: center;
      line-height: 36px;
      cursor: pointer;
      transition: all 0.3s ease;
      font-size: 14px;
    }
    .qr-tooltip:hover{
      transform: translateY(-3px);
      box-shadow: 0 10px 20px rgba(0,0,0,0.1);
      color: var(--primary-color);
    }

    .qr-tooltip .qr-code {
      visibility: hidden;
      width: 120px;
      height: 150px;
      background-color: #fff;
      color: #333;
      text-align: center;
      border-radius: 6px;
      padding: 10px;
      position: absolute;
      z-index: 1;
      bottom: 40px;
      left: 70px;
      transform: translateX(-50%);
      opacity: 0;
      transition: opacity 0.3s;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    .qr-tooltip .qr-code img {
      width: 100%;
      height: auto;
      margin-bottom: 5px;
    }

    .qr-tooltip:hover .qr-code {
      visibility: visible;
      opacity: 1;
    }

</style>



<!-- 页脚  -->
<section class="footer">
  <div class="container ">
    <div class="row g-4">
      <div class="col-lg-3">
        <img src="/images/txsjlogo.png" alt="Logo" class="mb-3 footer-Logo">
        <p class="text-muted">天下数据:做天下最好的IDC服务商</p>
        <div class="d-flex align-items-center mb-3 mt-3">
          <i class="fas fa-phone-alt me-3 fs-6"></i>
          <p class="mb-0 footer-txt">7×24小时销售热线:400-638-8808</p>
        </div>
        <div class="mt-4">
<!--          <h5 class="mb-3">关注我们</h5>-->
          <div class="d-flex align-items-center">
            <div class="qr-tooltip">
              <i class="fab fa-weixin"></i>
              <div class="qr-code">
                <img src="/images/idx_erwm.jpg" alt="微信二维码">
                <p>微信扫码关注</p>
              </div>
            </div>
            <div class="qr-tooltip">
              <i class="fab fa-weibo"></i>
              <div class="qr-code">
                <img src="/images/btm_xlang.jpg" alt="微博二维码">
                <p>微博扫码关注</p>
              </div>
            </div>
            <div class="qr-tooltip" onclick="window.open('https://url.cn/HNvbrciI?_type=wpa&qidian=true')">
              <i class="fab fa-qq"></i>
            </div>
            <div class="qr-tooltip" onclick="window.open('https://portal.idcbest.hk/login')">
              <i class="fas fa-sign-in-alt"></i>
            </div>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-2">
        <div class="footer-links">
          <h5 data-bs-toggle="collapse" data-bs-target="#productsCollapse" aria-expanded="false">
            服务器租用产品
            <span class="toggle-icon"><i class="fas fa-chevron-down"></i></span>
          </h5>
          <div id="productsCollapse" class="collapse">
            <ul>
              <li><a href="/server/" target="_blank">海外服务器租用</a></li>
              <li><a href="/server/xianggangfuwuqi/" target="_blank">香港服务器租用</a></li>
              <li><a href="/server/meiguofuwuqi/" target="_blank">美国服务器租用</a></li>
              <li><a href="/server/ribenfuwuqi/" target="_blank">日本服务器租用</a></li>
              <li><a href="/server/yingguofuwuqi/" target="_blank">英国服务器租用</a></li>
              <li><a href="/server/eluosifuwuqi/" target="_blank">俄罗斯服务器租用</a></li>
              <li><a href="/server/deguofuwuqi/" target="_blank">德国服务器租用</a></li>       
            </ul>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-2">
        <div class="footer-links">
          <h5 data-bs-toggle="collapse" data-bs-target="#helpCollapse" aria-expanded="false">
            云服务器租用产品
            <span class="toggle-icon"><i class="fas fa-chevron-down"></i></span>
          </h5>
          <div id="helpCollapse" class="collapse">
            <ul>
              <li><a href="/vps/" target="_blank">全球云服务器</a></li>
              <li><a href="/2021/qly" target="_blank">轻量云服务器</a></li>
              <li><a href="/vps/hk/" target="_blank">香港云服务器</a></li>
              <li><a href="/vps/usa/" target="_blank">美国云服务器</a></li>
              <li><a href="/vps/xjp/" target="_blank">新加坡云服务器</a></li>
              <li><a href="/vps/zl/" target="_blank">智利云服务器</a></li>  
              <li><a href="/vps/nrly/" target="_blank">尼日利亚云服务器</a></li>                      
            </ul>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-2">
        <div class="footer-links">
          <h5 data-bs-toggle="collapse" data-bs-target="#solutionsCollapse" aria-expanded="false">
            行业解决方案
            <span class="toggle-icon"><i class="fas fa-chevron-down"></i></span>
          </h5>
          <div id="solutionsCollapse" class="collapse">
            <ul>
              <li><a href="/jiejuefangan/hwyx/" target="_blank">游戏解决方案</a></li>
              <li><a href="/jiejuefangan/jr/" target="_blank">金融解决方案</a></li>
              <li><a href="/jiejuefangan/zx/" target="_blank">直销解决方案</a></li>
              <li><a href="/jiejuefangan/zq/" target="_blank">站群解决方案</a></li>
              <li><a href="/jiejuefangan/wzjl/" target="_blank">企业解决方案</a></li>
              <li><a href="/jiejuefangan/fzjh/" target="_blank">负载均衡解决方案</a></li>
              <li><a href="/jiejuefangan/lmt/" target="_blank">视频解决方案</a></li>
            </ul>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-2">
        <div class="footer-links">
          <h5 data-bs-toggle="collapse" data-bs-target="#aboutCollapse" aria-expanded="false">
            关于我们
            <span class="toggle-icon"><i class="fas fa-chevron-down"></i></span>
          </h5>
          <div id="aboutCollapse" class="collapse">
            <ul>
              <li><a href="/about/" target="_blank">公司介绍</a></li>
              <li><a href="/about/payment/" target="_blank">付款方式</a></li>
              <li><a href="/about/case/" target="_blank">合作伙伴</a></li>
              <li><a href="/about/rencai/" target="_blank">团队建设</a></li>
              <li><a href="/about/honor/" target="_blank">荣誉资质</a></li>
              <li><a href="/about/licheng/" target="_blank">公司发展</a></li>
              <li><a href="/about/rencai/" target="_blank">加入我们</a></li>
            </ul>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-1">
        <div class="footer-links">
          <h5 data-bs-toggle="collapse" data-bs-target="#linksCollapse" aria-expanded="false">
            联系我们
            <span class="toggle-icon"><i class="fas fa-chevron-down"></i></span>
          </h5>
          <div id="linksCollapse" class="collapse">
            <ul>
              <li><a href="/about/contact/" target="_blank">联系我们</a></li>
              <li><a href="/activities/" target="_blank">最新活动</a></li>
              <li><a href="/hangye/" target="_blank">行业新闻</a></li>
              <li><a href="/news/"  target="_blank">公司新闻</a></li>
              <li><a href="/mtbd/" target="_blank">媒体报道</a></li>
              <li><a href="/sitemap.xml" target="_blank">网站地图</a></li>
            </ul>
          </div>
        </div>
      </div>
    </div>

    <div class="copyright text-center">
      <p class="mb-0">《中华人民共和国增值电信业务经营许可证》 ISP证: 粤ICP备07026347号 <img src="https://www.idcbest.com/images/bottom_gswj.png" alt="" style="width: 30px"></p>
      <p class="mt-2">深圳总部:中国·深圳·南山区·国际创新谷六栋B座10层 </p>
      <p class="mt-2">香港分部:香港上環蘇杭街49-51號建安商業大廈7樓 香港服务电话:+852 67031102</p>
    </div>
  </div>
</section>

<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?e6b92cb05a34d37a410d6f20eaf917a3";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<!--底部  -->

<!-- 自定义JS -->
<script src="/js/top-bottom.js"></script>
</body>
</html>