--- agent: instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown." endpoint: "https://martech.zone/.well-known/search?q={query}" method: "GET" documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/" description: Print CSS is powerful and often underutilized when users choose to print. With @media print you can style only the printed page and hide unnecessary layout. title: "WordPress Print CSS: How to Make Your Blog Print and PDF Friendly" image: https://martech.zone/wp-content/uploads/2009/09/print-friendly-wordpress-plugin.webp --- ![WordPress Plugin: Print Friendly CSS](https://martech.zone/wp-content/uploads/2009/09/print-friendly-wordpress-plugin-420x236.webp "WordPress Plugin: Add Print-Friendly CSS To Your Site 1") Print stylesheets are a powerful, often underutilized feature of [CSS](https://martech.zone/acronym/css/) that allows developers to control how their web content appears when users choose to print a page. Using the `@media print` you can create styles that apply only when a document is being printed, hiding unnecessary layout elements, adjusting typography for legibility, and formatting content for paper. One effective strategy when crafting a print stylesheet is to begin by hiding everything on the page with a universal selector: ``` @media print { * { display: none !important; } } ``` From there, you selectively reveal only the parts of the page you want printed, such as an `
` element or a `.print-area` class. This approach ensures a clean and focused print output, free of headers, navigation bars, sidebars, and other on-screen clutter. To make this process easy and accessible to [WordPress](https://refer.martech.zone/wordpress/org/) site administrators, the **Custom Print Stylesheet** plugin below provides a full-featured interface for managing print-specific CSS. It includes: - A settings page under **Settings > Print CSS,** where administrators can edit the active print stylesheet. - A **Reset to Default CSS** button that restores a clean baseline style targeting only the `
` element. - A **Live Preview** that renders the most recent published post using the current print styles for quick visual feedback. - Built-in CSS rules to automatically hide [Google Ads](https://refer.martech.zone/google/ads/) and other commonly named ad containers during printing, so the output remains clean and professional. This plugin is ideal for bloggers, publishers, and anyone looking to offer a well-formatted printable version of their content without unnecessary extras. You can install it like any other plugin, modify the print CSS to suit your site’s structure, and give users a better printing experience in minutes. ``` element. Includes a reset button to restore default CSS and a live preview of the latest post. Version: 1.0 Author: Douglas Karr Author URI: https://dknewmedia.com */ add_action('admin_menu', 'custom_print_css_menu'); add_action('admin_init', 'custom_print_css_settings'); add_action('wp_head', 'custom_print_css_enqueue', 999); function custom_print_css_menu() { add_options_page( 'Custom Print CSS', 'Print CSS', 'manage_options', 'custom-print-css', 'custom_print_css_settings_page' ); } function custom_print_css_settings() { register_setting('custom_print_css_options', 'custom_print_css'); } function custom_print_css_settings_page() { if (!current_user_can('manage_options')) return; // Reset logic if (isset($_POST['reset_print_css'])) { check_admin_referer('custom_print_css_reset'); update_option('custom_print_css', custom_print_css_default()); echo '

Print CSS has been reset to default.

'; } $css = get_option('custom_print_css', custom_print_css_default()); ?>

Custom Print Stylesheet

Live Preview of Latest Post

This is how your current print CSS affects the most recent post:

\n" . $css . "\n"; } function custom_print_css_default() { return <<