我是靠谱客的博主 平淡冰淇淋,最近开发中收集的这篇文章主要介绍wordpress主页php,wordpress主页在哪,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

dd6ff0f1f7be6e9d832f45404204ea43.png

wordpress主页程序在哪?

● wp-content/themes/xxx/index.php,xxx指的是你使用的主题名称。下载下来用编辑软件打开即可修改。

● 一般index.php文件中,还包含了header.php,sidebar.php还有footer.php,你看看需要修改那里,就找到相应的文件去修改就好了。

WordPress简介

WordPress是使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。也可以把 WordPress当作一个内容管理系统(CMS)来使用。

WordPress是一款个人博客系统,并逐步演化成一款内容管理系统软件,它是使用PHP语言和MySQL数据库开发的,用户可以在支持 PHP 和 MySQL数据库的服务器上使用自己的博客。

WordPress有许多第三方开发的免费模板,安装方式简单易用。不过要做一个自己的模板,则需要你有一定的专业知识。比如你至少要懂的标准通用标记语言下的一个应用HTML代码、CSS、PHP等相关知识。

更多WordPress技术文章,请访问WordPress教程栏目!

最后

以上就是平淡冰淇淋为你收集整理的wordpress主页php,wordpress主页在哪的全部内容,希望文章能够帮你解决wordpress主页php,wordpress主页在哪所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

相关文章

php title内容,simple_html_dom.php类使用之一:获取<title>标题内容
php title内容,simple_html_dom.php类使用之一:获取标题内容</a></h5> </div> <div class="col-sm-3 col-xs-6"> <a href="/article/k-p-k_14_uzo_10_f5_13_jc1.html" class="img-zoom"> <div class="embed-responsive embed-responsive-4by3"> <img src="/uploads/reation/bcimg12.png" alt="帮你的WordPress博客添加主页、文章页的关键字和描述" class="embed-responsive-item"> </div> </a> <h5 class="text-center"><a href="/article/k-p-k_14_uzo_10_f5_13_jc1.html">帮你的WordPress博客添加主页、文章页的关键字和描述</a></h5> </div> <div class="col-sm-3 col-xs-6"> <a href="/article/k-p-k_14_uzo_10_f5_13_jc2.html" class="img-zoom"> <div class="embed-responsive embed-responsive-4by3"> <img src="/uploads/reation/bcimg13.png" alt="wordpress 表格文字对齐_wordpress商品网站主页头版设置方法" class="embed-responsive-item"> </div> </a> <h5 class="text-center"><a href="/article/k-p-k_14_uzo_10_f5_13_jc2.html">wordpress 表格文字对齐_wordpress商品网站主页头版设置方法</a></h5> </div> <div class="col-sm-3 col-xs-6"> <a href="/article/k-p-k_14_uzo_10_f5_13_jc3.html" class="img-zoom"> <div class="embed-responsive embed-responsive-4by3"> <img src="/uploads/reation/bcimg14.png" alt="wordpress主页php,wordpress主页在哪" class="embed-responsive-item"> </div> </a> <h5 class="text-center"><a href="/article/k-p-k_14_uzo_10_f5_13_jc3.html">wordpress主页php,wordpress主页在哪</a></h5> </div> <div class="col-sm-3 col-xs-6"> <a href="/article/k-p-k_14_uzo_10_f5_13_jc4.html" class="img-zoom"> <div class="embed-responsive embed-responsive-4by3"> <img src="/uploads/reation/bcimg1.png" alt="wordpress定义新的POST类型" class="embed-responsive-item"> </div> </a> <h5 class="text-center"><a href="/article/k-p-k_14_uzo_10_f5_13_jc4.html">wordpress定义新的POST类型</a></h5> </div> <div class="col-sm-3 col-xs-6"> <a href="/article/k-p-k_14_uzo_10_f5_13_jc5.html" class="img-zoom"> <div class="embed-responsive embed-responsive-4by3"> <img src="/uploads/reation/bcimg2.png" alt="WordPress获取所有分类列表函数:get_categories()" class="embed-responsive-item"> </div> </a> <h5 class="text-center"><a href="/article/k-p-k_14_uzo_10_f5_13_jc5.html">WordPress获取所有分类列表函数:get_categories()</a></h5> </div> <div class="col-sm-3 col-xs-6"> <a href="/article/k-p-k_14_uzo_10_f5_13_jgw.html" class="img-zoom"> <div class="embed-responsive embed-responsive-4by3"> <img src="/uploads/reation/bcimg3.png" alt="如何在wordpress中设置关键词和描述" class="embed-responsive-item"> </div> </a> <h5 class="text-center"><a href="/article/k-p-k_14_uzo_10_f5_13_jgw.html">如何在wordpress中设置关键词和描述</a></h5> </div> <!-- E 相关文章 --> </div> </div> <div class="clearfix"></div> </div> </div> <div class="panel panel-default" id="comments"> <div class="panel-heading"> <h3 class="panel-title">评论列表<small>共有 <span>0</span> 条评论</small></h3> </div> <div class="panel-body"> <div id="comment-container"> <!-- S 发表评论 --> <div id="postcomment"> <h3>发表评论 <a href="javascript:;"> <small>取消回复</small> </a></h3> <form action="/comment/post.html" method="post" id="postform"> <input type="hidden" name="__token__" value="d988064fa172fbc5697443c91220b5e1" /> <input type="hidden" name="type" value="archives"/> <input type="hidden" name="artid" value="349677"/> <input type="hidden" name="pid" id="pid" value="0"/> <div class="form-group"> <textarea name="content" class="form-control" disabled placeholder="请登录后再发表评论" id="commentcontent" cols="6" rows="5" tabindex="4"></textarea> </div> <div class="form-group"> <a href="/index/user/login.html" class="btn btn-primary">登录</a> <a href="/index/user/register.html" class="btn btn-outline-primary">注册新账号</a> </div> </form> </div> <!-- E 发表评论 --> </div> </div> </div> </main> <aside class="col-xs-12 col-md-4"> <!--@formatter:off--> <!-- S 关于作者 --> <div class="panel panel-default about-author no-padding" data-id="86912" itemProp="author" itemscope="" itemType="http://schema.org/Person"> <meta itemProp="name" content="平淡冰淇淋"/> <meta itemProp="image" content="/assets/img/avatar.png"/> <meta itemProp="url" content="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_.html"/> <div class="panel-body no-padding"> <div class="author-card"> <div class="author-head" style="background-image:url('/assets/img/author-head.jpeg');"></div> <div class="author-avatar"> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_.html"> <img src="/assets/img/avatar.png"> </a> </div> <div class="author-basic"> <div class="author-nickname"> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_.html">平淡冰淇淋</a> </div> <span class="text-muted"></span> </div> <div class="row author-statistics"> <div class="col-xs-4"> <div class="statistics-text">文章</div> <div class="statistics-nums"><a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_.html">4</a></div> </div> <div class="col-xs-4"> <div class="statistics-text">资源</div> <div class="statistics-nums"><a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_.html?type=soft">0</a></div> </div> <div class="col-xs-4"> <div class="statistics-text">加入时间</div> <div class="statistics-nums">2年前</div> </div> </div> </div> </div> </div> <!-- E 关于作者 --> <!--@formatter:on--> <div class="panel panel-blockimg"> </div> <!-- S 热门文章 --> <div class="panel panel-default hot-article"> <div class="panel-heading"> <h3 class="panel-title">热门文章</h3> </div> <div class="panel-body"> <div class="media media-number"> <div class="media-left"> <span class="num tag">1</span> </div> <div class="media-body"> <a class="link-dark" href="/article/k-p-k_13_u_23_o_6_f3_14_j_18__27_.html" title="教你SQLSERVER扩展存储过程XP_CMDSHELL的简单应用 ">教你SQLSERVER扩展存储过程XP_CMDSHELL的简单应用 </a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">2</span> </div> <div class="media-body"> <a class="link-dark" href="/article/k-p-k_14_u_7_o_10_f1_13__7__22_4.html" title="nginx中path模式配置示例">nginx中path模式配置示例</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">3</span> </div> <div class="media-body"> <a class="link-dark" href="/article/k-p-k_14_ujo_10_fw_14_j_22_y.html" title="前端开发是什么?前端开发是什么意思">前端开发是什么?前端开发是什么意思</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">4</span> </div> <div class="media-body"> <a class="link-dark" href="/article/k-p-k_14_uzo_10_f5_13_jc3.html" title="wordpress主页php,wordpress主页在哪">wordpress主页php,wordpress主页在哪</a> </div> </div> </div> </div> <!-- E 热门文章 --> <!-- S 热门资讯 --> <div class="panel panel-default hot-article"> <div class="panel-heading"> <h3 class="panel-title">推荐资讯</h3> </div> <div class="panel-body"> <div class="media media-number"> <div class="media-left"> <span class="num tag">1</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_u_7_ogf2_14__23__6__27_.html" title="暖气费别忘交 国家气候中心:今年冬天较易出现强降温、强降雪">暖气费别忘交 国家气候中心:今年冬天较易出现强降温、强降雪</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">2</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_u_7_ogf1_13_j_14__27_.html" title="苹果喊话iPhone 13和14钉子户换机 宋紫薇:苹果营销真接地气苹果向 iPhone 13 和 14 用户发出升级呼吁">苹果喊话iPhone 13和14钉子户换机 宋紫薇:苹果营销真接地气苹果向 iPhone 13 和 14 用户发出升级呼吁</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">3</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_ujo_26_fx_13_zk_27_.html" title="小鹏汽车发布“公司史上最强财报”:第三季度总营收 101 亿元同比增长 18.4%,净亏损 18.1 亿元">小鹏汽车发布“公司史上最强财报”:第三季度总营收 101 亿元同比增长 18.4%,净亏损 18.1 亿元</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">4</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_u_7_ogf4_13__23_k_27_.html" title="iPhone 16系列首销4周销量不及15系列:果粉换机动力不足">iPhone 16系列首销4周销量不及15系列:果粉换机动力不足</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">5</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_u_7_ogf4_13__7__26__27_.html" title="开始执行!无有效认证证书电动自行车不能上牌、上路:限速25公里每小时等">开始执行!无有效认证证书电动自行车不能上牌、上路:限速25公里每小时等</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">6</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_ujo_26_fy_13__7__22__27_.html" title="360 数科:香港上市发行价 50.03 港元 / 股,获 2.46 倍认购">360 数科:香港上市发行价 50.03 港元 / 股,获 2.46 倍认购</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">7</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_ujo_26_fy_13__23_k_27_.html" title="原 360 借条运营方奇富科技 Q3 净利润 17.99 亿元,同比增加 58.11%">原 360 借条运营方奇富科技 Q3 净利润 17.99 亿元,同比增加 58.11%</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">8</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_ujo_26_fy_13__7__26__27_.html" title="360 数科更名奇富科技,全面拥抱金融科技新战略">360 数科更名奇富科技,全面拥抱金融科技新战略</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">9</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_u_7_ogf4_13__23_g_27_.html" title="不提倡称呼哥/姐、飞书不显示职级性别!字节跳动官方解释企业文化字节跳动企业文化诠释">不提倡称呼哥/姐、飞书不显示职级性别!字节跳动官方解释企业文化字节跳动企业文化诠释</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">10</span> </div> <div class="media-body"> <a class="link-dark" href="/news/k-p-k_13_u_7_okf1_14__7_g_27_.html" title="2024 广州国际车展展位图公布,11 月 15 日开幕">2024 广州国际车展展位图公布,11 月 15 日开幕</a> </div> </div> </div> </div> <!-- E 热门资讯 --> <div class="panel panel-blockimg"> <a href="https://www.aliyun.com/daily-act/ecs/activity_selection?userCode=2qwpuaqd" rel="nofollow" title="推荐企业服务器" target="_blank"> <img src="/uploads/store/aliyun-sidebar.png" class="img-responsive" alt=""> </a> </div> <!-- S 热门标签 --> <div class="panel panel-default hot-tags"> <div class="panel-heading"> <h3 class="panel-title">热门标签</h3> </div> <div class="panel-body"> <div class="tags"> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_/category/k-p-k_14_uzo_6_fw_13_z_2__27_.html" class="tag"> <span>JSP编程</span></a> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_/category/k-p-k_14_u_7_o_10_f3_12__7_kx.html" class="tag"> <span>JavaScript</span></a> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_/category/k-p-k_14_u_7_o_6_fy_14_z_2_w.html" class="tag"> <span>系统进程</span></a> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_/category/k-p-k_14_ujocfz_14_j_18_3.html" class="tag"> <span>MongoDB</span></a> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_/category/k-p-k_14_uzo_18_f4_13__7__2_y.html" class="tag"> <span>安全教程</span></a> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_/category/k-p-k_13_u_23_o_22_fx_14__23__10_5.html" class="tag"> <span>Nginx</span></a> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_/category/k-p-k_13_u_23_ogf4_14__7_c3.html" class="tag"> <span>前端开发</span></a> <a href="/u/k-p-k_12_u_23_o_2_f5_14__7__18__27_/category/k-p-k_13_u_7_okf2_12__7__22_z.html" class="tag"> <span>wordpress主页php</span></a> </div> </div> </div> <!-- E 热门标签 --> <!-- S 推荐下载 --> <div class="panel panel-default recommend-article"> <div class="panel-heading"> <h3 class="panel-title">推荐下载</h3> </div> <div class="panel-body"> <div class="media media-number"> <div class="media-left"> <span class="num tag">1</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fy_13_w_27__27_.html" title="VMware Workstation Pro 17.5.2 纯天然绿色完整版下载">VMware Workstation Pro 17.5.2 纯天然绿色完整版下载</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">2</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fz_14_w_27__27_.html" title="PhpStudy8.1小皮面板">PhpStudy8.1小皮面板</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">3</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fz_14__10__27__27_.html" title="视频音频编辑软件 Adobe Premiere Pro 2020 绿色便携免费版">视频音频编辑软件 Adobe Premiere Pro 2020 绿色便携免费版</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">4</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fy_14_w_27__27_.html" title="火焰纹章 无双|官方中文|本体+1.5.0升补+5DLC | [NSP]">火焰纹章 无双|官方中文|本体+1.5.0升补+5DLC | [NSP]</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">5</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fz_14__26__27__27_.html" title="Photoshop CS6 中文汉化精简版">Photoshop CS6 中文汉化精简版</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">6</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fy_13__10__27__27_.html" title="Adobe Fireworks CS6绿色精简版下载">Adobe Fireworks CS6绿色精简版下载</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">7</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fy_12__10__27__27_.html" title="Photoshop CS6 Extend 绿色增强版">Photoshop CS6 Extend 绿色增强版</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">8</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fy_13__26__27__27_.html" title="Adobe FireWorks cs5【FW cs5 】中文绿色版下载">Adobe FireWorks cs5【FW cs5 】中文绿色版下载</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">9</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fy_12__26__27__27_.html" title="Photoshop CS6中文精简版">Photoshop CS6中文精简版</a> </div> </div> <div class="media media-number"> <div class="media-left"> <span class="num tag">10</span> </div> <div class="media-body"> <a href="/soft/k-p-k_12_u_7_o_10_fz_12__10__27__27_.html" title="古龙风云录|中字-国语|Build.14142398-重要更新-狂雷陨落-剑破苍穹+DLC+修改器|解压即玩">古龙风云录|中字-国语|Build.14142398-重要更新-狂雷陨落-剑破苍穹+DLC+修改器|解压即玩</a> </div> </div> </div> </div> <!-- E 推荐下载 --> <div class="panel panel-blockimg"> <a href="/" target="_blank"><img src="/uploads/store/enterprisehost.png" class="img-responsive"/></a> </div> <div class="panel panel-blockimg"> <!-- You may also like --> </div> </aside> </div> </div> </main> <footer> <!-- S 底部版权 --> <div id="footer"> <div class="container"> <div class="row footer-inner"> <div class="col-xs-12"> <div class="pull-left"> <p>网站内容,均来自于用户原创和互联网,若有侵犯到您的权益请联系我们,核实删除。</p> <p>本站为非营利性网站,靠谱客的资源均来自网络收集整理,个人纯属学习交流之用,如有侵犯您的版权请与我联系(wx:kaopuke),我们会马上改正并在下载24小时内删除!</p> <p>Copyright © 2023 All Rights Reserved. <a href="https://beian.miit.gov.cn" rel="nofollow" target="_blank">黔ICP备17011320号-2</a> <a href="https://beian.mps.gov.cn/#/query/webSearch?code=52272602002071" rel="noreferrer" target="_blank">贵公网安备52272602002071</a></p> </div> </div> </div> </div> </div> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?e749fb7b04b857116f3a8b682641b74d"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <!-- E 底部版权 --> </footer> <div id="floatbtn"> <!-- S 浮动按钮 --> <a class="hover" href="/index/user/addarticle.html" target="_blank"> <i class="fa fa-paint-brush fa-lg"></i> <em>立即<br>投稿</em> </a> <div class="floatbtn-item floatbtn-share"> <i class="fa fa-share-alt fa-lg"></i> <div class="floatbtn-wrapper" style="height:50px;top:0"> <div class="social-share" data-initialized="true" data-mode="prepend"> <a href="#" class="social-share-icon icon-weibo" target="_blank"></a> <a href="#" class="social-share-icon icon-qq" target="_blank"></a> <a href="#" class="social-share-icon icon-qzone" target="_blank"></a> <a href="#" class="social-share-icon icon-wechat"></a> </div> </div> </div> <a id="back-to-top" class="hover" href="javascript:;"> <i class="fa fa-reply fa-lg"></i> <em>返回<br>顶部</em> </a> <!-- E 浮动按钮 --> </div> <script type="text/javascript" src="/assets/libs/jquery/dist/jquery.min.js?v=1.0.2"></script> <script type="text/javascript" src="/assets/libs/bootstrap/dist/js/bootstrap.min.js?v=1.0.2"></script> <script type="text/javascript" src="/assets/libs/fastadmin-layer/dist/layer.js?v=1.0.2"></script> <script type="text/javascript" src="/assets/libs/art-template/dist/template-native.js?v=1.0.2"></script> <script type="text/javascript" src="/assets/js/jquery.autocomplete.js?v=1.0.2"></script> <script type="text/javascript" src="/assets/js/swiper.min.js?v=1.0.2"></script> <script type="text/javascript" src="/assets/js/share.min.js?v=1.0.2"></script> <script type="text/javascript" src="/assets/js/cms.js?v=1.0.2"></script> <script type="text/javascript" src="/assets/js/common.js?v=1.0.2"></script> <script type="text/javascript"> (window.slotbydup = window.slotbydup || []).push({ id: "u6850766", container: "_upguagn2t8", async: true }); (window.slotbydup = window.slotbydup || []).push({ id: "u6850838", container: "_12s5gcmjcvx", async: true }); </script> <script type="text/javascript" src="//cpro.baidustatic.com/cpro/ui/cm.js" async="async" defer="defer" ></script> <!-- 复制 --> <script src="/static/tool/clipboard.min.js"></script> <script> //代码高亮溢出显示滚动条 $('.main-content pre').each(function(){ var code = $(this).text(); $(this).wrap('<div class="auto" style="overflow:auto; position:relative;"></div>'); $(this).before('<span class="copyCode">复制代码</span><textarea style="display:none;">'+code+'</textarea>'); $(this).removeAttr("style",""); // $(this).wrap('<pre><code></code></pre>'); }); $('.main-content .codebody').each(function(){ var code = $(this).text(); $(this).wrap('<div class="auto" style="overflow:auto; position:relative;"></div>'); $(this).before('<span class="copyCode">复制代码</span><textarea style="display:none;">'+code+'</textarea>'); // $(this).wrap('<pre><code></code></pre>'); }); function unescapeSpecialChars(str) { return str .replace(/</g, '<') .replace(/>/g, '>') .replace(/&/g, '&') .replace(/ /g, ' ') .replace(/"/g, '"') .replace(/'/g, '\''); } //复制代码 $('.copyCode').on('click',function(){ var txt = $(this).next().html(); txt = unescapeSpecialChars(txt); new ClipboardJS('.copyCode', {text: function() {return txt;}}); layer.msg('复制成功',{time:1000,offset:'100px'}); }); </script> <script> document.addEventListener("DOMContentLoaded", function() { const preElements = document.querySelectorAll("pre"); // 获取所有 <pre> 元素 preElements.forEach(pre => { const codeText = pre.innerHTML.trim(); // 获取代码块的内容 const lines = codeText.split("\n").length; // 计算代码行数 // 创建行号容器 const lineNumbers = document.createElement("div"); lineNumbers.className = 'line-numbers'; // 生成行号内容 let lineNumbersHtml = ''; for (let i = 1; i <= lines; i++) { lineNumbersHtml += i + '<br>'; } // 插入行号容器到 pre 元素中 lineNumbers.innerHTML = lineNumbersHtml; pre.appendChild(lineNumbers); // 保持代码块的格式化 pre.innerHTML = `<div class="line-numbers">${lineNumbersHtml}</div>` + `<div style="padding-left:40px;">${codeText}</div>`; }); }); </script> <style> .copyCode{ position:absolute; right:1px; z-index:999; background:rgba(255,255,255,0.5); border-bottom:1px solid #ddd; padding:2px 8px; font-size:11px !important; border-radius:4px; line-height:24px; cursor:pointer; } .copyCode:hover{ background:#fff; } pre code{ font-family: consolas, Menlo, "PingFang SC", "Microsoft YaHei", monospace; } .hljs { border-radius:4px; padding: 8px !important; } .hljs-ln td { padding: 2px 8px; } .hljs-ln-numbers { text-align: center; color: #abb2bf; background-color: #282c34; border-right: 1px solid #c5c5c5; vertical-align: top; } /* for block of code */ td .hljs-ln-code { padding-left: 5px; } pre { position: relative; padding-left: 5px; /* 为行号留出空间 */ background-color: #f8f9fa; border: 1px solid #e1e1e1; border-radius: 4px; font-size: 14px; line-height: 1.5; overflow-x: auto; } /* 设置行号样式 */ pre .line-numbers { position: absolute; left: 0; top: 0; padding: 10px 10px; background-color: #f1f1f1; border-right: 1px solid #e1e1e1; text-align: right; user-select: none; color: #888; } </style> </body> </html>