I am new to WordPress framework. May I know how I can link an external CSS and JS file to my WordPress page? I have created a new page, but I would like to link a CSS and JS file to it.
Is creating a new template or plugin a solution? I am totally new to this.
I know this thread is a little dated but perhaps someone else might find it useful.
The proper way to include external CSS and JS files would be to use the
wp_enqueue_style method
and using theesc_url_raw
on the source parameter.For example to include t a google font into your theme you would od the following:
Depends if you want to add your CSS or JS conditionnaly. If you want them to be included in all files, just use the functions.php page of your theme folder, and add :
For the stylesheet, proceed this way :
Use the “Insert Header and Footer” wordpress plug-in. It does all the job for you! Just paste what should be in your into the header section of the plug-in.
You can add files to your current theme. Add css-files to header (header.php in your theme folder). And add js-files to footer (footer.php in your theme folder). Theme folder can be found in path wp-content/themes/
You can modify header.php file of your theme to include external JS and CSS files. Header.php is located in wp-content>themes>currently active theme>header.php.
Open it in an editor and include a link to external or files between
<head></head>
tag.You don’t need to create a plugin or a new template to link to a file within an existing WordPress theme.
As suggested if you open up your themes header.php and before the closing tag you can insert a link to the file location.
Your CSS file will generally reside within your theme folder:
wp-content/themes/your_theme/style.css
You can call the stylesheet using the following WordPress function:
Take a look at the following WordPress Codex section for info:
http://codex.wordpress.org/Function_Reference/bloginfo
You don’t need to purchase any plugin, just open function.php file inside your root directory of WordPress theme. and just insert this function PFB, just change the directory, for js you don’t need to connect a separate file because you can use footer.php and insert your js code in script tag it will work accurately.