As long as you can identify the specific elements you want the new styles to apply to. This is usually done by using specificity.
A lot depends on how you’ve coded your special page. If you’ve used standard WordPress calls that do things like add the standard ids and classes that WordPress uses (e.g. <body class="home">...) then you can easily identify, say, paragraphs on the home page by using some CSS like:
p.home{...}
But as I said in my last post, you can link to a special style sheet, but you just have to make sure you construct the proper URL. In WordPress you always have to use absolute URLs – because pages are never called directly but are, rather, included into other pages. Since you can’t be sure of the location of the including page you can never use an address relative to it. The address has to be absolute so that the location of the including PHP file is not relevant.
HTH
I’ve combined all styles to be in the one child theme style sheet. so any new css rule is in that file.
By doing that it should be enough to just have the normal
<link href=”../KidTheme/style.css” rel=”stylesheet” type=”text/css”>
on all pages that use the css-file right?
My Home Page template is written as I would write any other normal page except that it has the <?php /* Template Name: Home Page
*/ ?> at the top.
So I haven’t used any template files belonging to the Twenty Eleven theme.
Please note what I said. You can’t use a relative href to a style sheet in WordPress.
Also, since you’re using the standard style sheet name, you don’t need to include it anyway. WordPress automatically uses style.css if it’s located in the child theme’s directory. You just need to make sure that the file contains the mandatory comments block as the first lines in style.css and that it includes the parent’s style sheet by containing the following @import statement immediately after the mandatory comment block:
@import url('../parentthemedirectoryname/style.css');
After the @import statement you add the style rules specific to your child.
Your child theme folder should contain the mandatory style sheet with the contents I detail above in this post, plus any template files that are different from the parent theme’s equivalents and any template files that do not exist in the parent such as template files for custom page types.
A minimal child theme contains only the style.css file formatted as above, with just the comments and the @import statement. Such a minimal child theme would look and behave exactly like its parent.
HTH
PAE
I’ve done all that. The CSS file has the mandatory comment block and the @import line immediately after.
So by not use a relative href are you saying that I should’t attach the stylesheet in my html file? That wordpress takes care of that.
What I’m saying is that if the stylesheet you want to use is the standard style.css file then it will be included by your theme’s header.php file.
If you aren’t using the theme’s header.php file or have modified it so that it no longer includes the standard stylesheet then yes, you’ll have to include it yourself. Just copy the code from your parent theme’s header.php file.
You can’t link to a stylesheet into a WordPress theme using a relative address for all the reasons I’ve already explained to you. You can link to stylesheet using code that constructs an absolute URL, such as:
<link type="text/css" rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" />
See:
http://codex.wordpress.org/Function_Reference/bloginfo
HTH
PAE
YES! we’ve got it working π
At least the CSS. I suppose I have to do something similar with JavaScript right?
If you’re trying to import a JavaScript file then, yes, you need to use an absolute URL. Construct it using bloginfo(). For instance, if you’ve put the JavaScript file into a directory called ‘scripts’ off your child theme’s directory, and if your JavaScript file was called ‘myjava.js’, then you’d construct the URL using:
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/scripts/myjava.js" />
HTH
PAE