• 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:

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

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

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' );
}

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;

<div class="print"><a rel="nofollow">Print This!</a></div>

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.

// 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' );
}

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.

.print {

}

That’s it!

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

Reader Interactions

© 2019 · Fat Cat Designs

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkNoRead more
Revoke Consent