Recently, I found many problems in the blog. First, I found that the picture black box and the JS QR code were invalid. Then, I clicked the reply button to refresh the page directly, but there was no comment box to follow the effect. Today, even the CSS icon on the website was hung...
I couldn't bear it. I decided to take a moment to see what the problem was. I didn't find an obvious error when I opened F12. Since it was the CSS icon hanging, it should be that there was a problem with the CSS address of my external link to fontawesome. So I filtered the address and found it was 301??
Similar situations are as follows:
it turns out to be the case that cdn.bootcss.com CDN resources of all jump to cdnjs.com Home page (this practice is a little drunk), and many functions of my blog have quoted this CDN, so it is abnormal!
Finally, a replacement CDN was found: https://cdnjs.net/ After the replacement, the functions such as image black box, QR code, CSS icon and delayed loading are restored, but the comment reply button is still refreshed abnormally!
Finally, I talked with Brother Bird. He said that it was the upgrade of WordPress to 5.1.1. After searching on the Internet, I found that I was out. Many blogs have provided solutions, such as Yigujin blog:《 What if the WordPress 5.1 comment reply button fails and the comment box does not follow? 》。
However, Brother Bird gave me a simpler solution (to avoid the trouble of refreshing CDN cache and browser cache):
For the start topic, directly find the zmingcx_scripts function in functions.php, and add the following before the last}:
//Load reply js if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); }
This code actually loads a JS on the page:
<script type='text/javascript' src='/wp-includes/js/comment-reply.min.js? ver=5.1.1'></script>
Therefore, for non start topics, just add the following code to the topic header.php:
<? php if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { ?> <script type='text/javascript' src='/wp-includes/js/comment-reply.min.js? ver=5.1.1'></script> <? php } ?>
This will solve the problem!