Can anyone tell me how can i add a code to head.php of the theme via a plugin?
I want to add some external .css file in it?
You should use following code in your plugin:
add_action('wp_head', 'your_function');
function your_function(){
wp_register_style( 'external_css', 'EXTERNAL CSS PATH');
wp_enqueue_style('external_css');
}
FYI: May be you mention incomplete file name, it's should be header.php, please make sure. Hope this code helps you. All the best ;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.