Child Theme print.css file
-
URL referenced: http://www.greggcountygop.com
As with the child theme’s
style.css
, I created aprint.css
and put it in the child theme folder. I want to exclude adiv
from the printed document, but not exclude all images. Here’s what I have in the child’sprint.css
file:/*
Theme Name: Graphene Child
Theme URI: http://www.khairul-syahir.com/wordpress-dev/graphene-theme
Description: Child theme for the Graphene theme
Author: John L. Rothra
Author URI: http://www.jrothraministries.com/
Template: graphene
Version: 1.0
*/
@import url("../graphene/print.css");
/* =Exclude from Printed Version
*/
#actioncenter {
display:none;
}After doing this and even after refreshing, when I do a print preview, the
actioncenter
div remains. Did I mess up somewhere?Hi,
I gotta say, that was a valiant effort!! And thanks for at least trying before asking 🙂
However, it’s not gonna work the way you’re going.
Instead, insert this into your child theme
functions.php
file:function graphene_extra_print_styles(){
wp_enqueue_style( 'graphene-child-light', get_stylesheet_directory_uri() . '/print.css' );
}
add_action( 'wp_print_styles', 'graphene_extra_print_styles', 1000 );Then, take delete the
print.css
file from your graphene child directory.Lastly, add the
#actioncenter {
display:none;
}to your child theme
style.css
file.This should do the trick.
ModAnother way is to use the
wp_head()
action to add a link to your stylesheet. In my child theme’s functions file I have:add_action ('wp_head', 'printstyle' );
function printstyle() {
echo "<link rel='stylesheet' id='graphene-stylesheet-css' href='http://blog.kjodle.net/wp-content/themes/graphene-stonesinwater/print.css' type='text/css' media='print' />";
}I include that in both my bookblog and my personal blog, so they both use the same print style sheet.
If there are only one or two items that you want to exclude from printing, you can always add them to your custom CSS option, like this:
@media print {
div.actioncenter {display:none;}
}
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.