• Skip to primary navigation
  • Skip to main content
  • Contact
    • About
    • Terms of Service
    • Privacy Policy

Fat Cat Designs

Bespoke Web Design

  • Blog
  • Tutorials

How To Add A Print Stylesheet & Button To Genesis

by Debra Scott

Step 1.
Create a file called print.css
There are a number of styles you can add, but the basic style of print.css is this:

[css]/* Print Style Sheet */
@media print {
body { background:white; color:black; margin:0 }
}[/css]

Step 2.
Upload this newly created file to your Genesis child theme directory via FTP or cpanel

Step 3.
Add the call to this new stylesheet in your child theme functions.php

[php]add_action( ‘wp_enqueue_scripts’, ‘child_print_style’ );
/**
*Print Style Sheet
*/
function child_print_style() {
wp_enqueue_style( ‘child_print_style’, $src = CHILD_URL . ‘/print.css’, ‘false’, ‘1.0.0’, ‘print’ );
}[/php]

Step 4.
Next we can add a link and print popup to single posts by creating a new php file. This file will be called print.php and should be added to your child theme directory. Place the following content in the file;

[html]

Print This!

[/html]

Step 5.
Now you will need to show this in your single post template so also add this to your child theme functions.php

Warning:

do not add this to functions without first creating and uploading print.php or you may experience errors or white screen on your site.

[php]
// Add Print Button after single post
add_action( ‘genesis_after_post_content’, ‘child_include_print’, 9 );
function child_include_print() {
if( is_single() )
require( CHILD_DIR.’/print.php’ );
}[/php]

Step 6.
If you would like to change the font, font size, background or float of your print button add this to your child theme’s style.css file and style as desired.

[css].print {

}[/css]

That’s it!

Filed Under: Tutorial Tagged With: Genesis, print-stylesheet, tutorial

© 2023 · Fat Cat Designs