Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
can anyone tell me how can i add a code to head.php of the theme via a plugin ?

What is the command for it? code to head.php of the theme via a plugin i want to add some external .css file in it?

share|improve this question
The average plugin does not have a head.php. Please make your question more clear. – toscho Sep 17 '12 at 10:52

closed as not a real question by kaiser, Michael, Wyck, toscho Sep 18 '12 at 2:04

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

You should use following code in your plugin:

add_action('wp_enqueue_scripts', 'your_function');
function your_function(){
     wp_register_style( 'external_css', 'EXTERNAL CSS PATH');           
     wp_enqueue_style('external_css');

     //echo '<link rel="stylesheet" type="text/css" media="all" href="EXTERNAL CSS PATH" />';
    }

Hope this code helps you. All the best ;)

share|improve this answer
2  
You should enqueue your css and javascript: codex.wordpress.org/Function_Reference/wp_enqueue_style – janw Sep 17 '12 at 10:55
Thanks janw to notice my answer. yes, you are also right, but in question user142187 mention some external css, so I amuse user142187 wants to use other site's css not saved on his own server, so I used it. thanks – techguy4web Sep 17 '12 at 11:01
You can set the $src both for scripts and styles to external files. – kaiser Sep 17 '12 at 11:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.