# Print Button Shortcode

> Adds a [print_button] shortcode that places a button visitors can click to print the current page, useful for recipes, guides and forms.

- Type: PHP
- Runs: Run everywhere
- Category: [Content](https://wpide.com/library/category/content/)
- Tags: shortcode, print, button
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/print-button-shortcode/

## Code

```php
add_shortcode( 'print_button', function ( $atts ) {
    $atts = shortcode_atts( array( 'label' => 'Print this page' ), $atts, 'print_button' );

    return '<button type="button" class="wp-element-button wpide-print-button" onclick="window.print();">' . esc_html( $atts['label'] ) . '</button>';
} );
```

## Notes

Change the label with [print_button label="Print this recipe"].

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Print Button Shortcode" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
