为什么不使用一个条件标记从子主题函数文件中将其钩住呢。
function facebook_comments_sdk_script() {
wp_enqueue_script( \'facebook-sdk\', get_bloginfo( \'stylesheet_directory\' ) .
\'/js/fb-comments.js\', array(), \'1.0.0\', true );
}
add_action( \'wp_enqueue_scripts\', \'facebook_comments_sdk_script\' );
function load_facebook_comments_form() {
if ( comments_open() ) {
echo \'<div class="fb-comments" data-href="http://example.com/comments"
data-numposts="5" data-colorscheme="light"></div>\';
}
}
add_action(\'comment_form\', \'load_facebook_comments_form\');
我还从Javascript SDK中删除了脚本标记,并将其放入如下文件中:
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=123456789224439";
fjs.parentNode.insertBefore(js, fjs);
}(document, \'script\', \'facebook-jssdk\'));