【技术水贴】Markup markdwown 插件导致worldpress新建页面 js代码失效,一招搞定

你是慕鸢呀~ 发布于 3 天前 3 次阅读 241 字 预计阅读时间: 1 分钟


AI 摘要

Title: 【Technical Tip】Fix WordPress New Page JS Code Failure Caused by Markup Markdown Plugin in One Move Content: Today, I opened my blog and found that the poetry on the "Recite Poetry" page wasn't loading—it was stuck on "Selecting...". My first thought was whether the poetry API had broken down, but after testing it locally, it worked fine. Then, I tried creating a new page and inserting the code, but it still didn't work—the JavaScript code wasn't executing. After some troubleshooting, I discovered that the Markup Markdown editor plugin was preventing the JS code from running. However, I couldn't simply remove the plugin, as it would mess up the formatting of my articles. The temporary solution I found was to place the JS code in the footer section while keeping the HTML code in place. HTML Code: ```sh Recite Two Lines of Poetry Selecting... ``` JS Code: ```sh // Insert your JavaScript code here ``` Now it's working properly again. Feel free to check out the [Recite Poetry](https://www.muyuanhuck.cn/learn/) page on my blog.

因是今天打开自己的博客,吟诗页面的诗词竟然不加载了,就一直是挑选中,我的第一反应是,是不是诗词api坏掉了,本地实验了一下是好的。

fb0980cd-3cd9-4ee3-b49b-893de23e3f25

然后我尝试了一下新建页面,插入代码,还是不行,不能执行代码

F12发现,调用接口的js代码并没有执行,经过多方排查,发现是因为 Markup markdwown 这个md编辑器插件干掉了js代码执行。

但是又不能直接干掉这个插件,会导致文章排版错乱。

最后的的权宜之计是:把js代码放到页脚代码那里,html代码保留

html代码


<div class="poem-wrap">
    <div class="poem-border poem-left"></div>
    <div class="poem-border poem-right"></div>

<h1>念两句诗</h1>
    <p id="jinrishici-sentence">挑选中....</p>
    <p id="info">
</div>

js代码

  <script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>

现在就正常了

image-20250929145834867

欢迎大家来吟诗

我本桀骜少年臣,不信鬼神不信人。
最后更新于 2025-09-29