I know that to link your WordPress main style.css
file you use:
<link href="<?php bloginfo('stylesheet_url');?>"rel="stylesheet" type="text/css"/>
However I have quite a few CSS files that need to be linked to the main PHP file for things like sliders, picture boxes etc…
I’m not quite sure how I would do that because the <?php bloginfo('stylesheet_url');?>
only works for the stylesheet that is named styles.css
and my other stylesheets all have different names.
Does anyone know how I can ink them all in?
Just put all of your stylesheets in a directory
wp-contentthemestwentyelevencss
.Then you can link all these by simply put below code-enjoy coding.
Your source code doesn’t include a filename… bloginfo(‘stylesheet_url’) only returns the link to your stylesheet…folder URL, usually the theme folder. You need to also append the folder (if one) and the filename.css
Remember to always code with WordPress standards in mind. Linking to a stylesheet is not a best practice. This enables proper caching and efficiency and is easier in the long run.
From the free 300 page book I read last weekend – WordPress AJAX, pg 53:
Put this in your functions.php or your header.php. It properly conditionally loads a stylesheet for the IE’s…
Are the CSS file in the current theme’s folder? If so, then try this code:
It works for me.
Probably the easiest way to add a style to your theme page if you are going to hardcode it would be:
1) Add your stylesheet to your stylsheet directory.
2) Paste in this code into your head (replacing style2.css with whatever you stylesheet name is).
or
If your styles are in a separate folder, just make sure to append that folder to your path (ie. /styles/style2.css)
Edit: Made answer more specific to add style links to the head and fixed my dumb mistake of src= when it should be href=
you can use
wp_enqueue_style()
function in wordpress here. example.and you can use the action
wp_enqueue_styles