每个人我是WP的新手,正在尝试构建插件。我有以下代码正常工作:
add_filter(\'the_content\', \'say_hello\');
function say_hello($content){
if(is_single() || is_page()){
print $content." Thank you for reading!";
} else {
print $content;
}
}
但以下代码似乎不起作用:
add_action(\'init\', \'prepare_head\');
function prepare_head(){
if(is_single() || is_page()){
// include javascripts
wp_enqueue_script("jquery");
//some more js goes here (registered and enqueued)...
//include css
$styleSrc = plugins_url("css/style.css", __FILE__);
wp_register_style("say_hello_style", $styleSrc);
wp_enqueue_style("say_hello_style");
}
}
我做错了吗?非常感谢您的帮助!谢谢