Register Print CSS

Marko Krstić
19 Jan 2020

after the file path add array, version and then print

<php
wp_enqueue_style( 'print_css', plugin_dir_url( __FILE__ ) . 'assets/css/print.css', array(), '1.0.0', 'print' );

An entire block stored in function.php should look like this.

You can always add it as @media print but with this you will have much more flexibility and load it where you need it.

<php
// Styles
function theme_styles() {
    wp_enqueue_style( 'print_css', plugin_dir_url( __FILE__ ) . 'assets/css/print.css', array(), '1.0.0', 'print' );
}
add_action( 'wp_enqueue_scripts', 'theme_styles',  1000, 1 ) ;

More about Print CSS:

https://www.sitepoint.com/css-printer-friendly-pages/

https://www.smashingmagazine.com/2018/05/print-stylesheets-in-2018/

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy