[print_post]
The shortcode creates a printable version of a specific section of a post or page.
Product
Shortcode Attributes
- target_selector – Specifies the CSS selector of the element(s) to be printed. This should match the container or section of the page to be included in the printed output.
- Default:
.main-content .page-elements. - Options: Refer to CSS Selector Guide
- Default:
- class – Adds a custom CSS class to the generated
<a>tag. This allows you to style the print button using your theme’s CSS.- Options: Any text value.
Example Usage
Example
[print_post class="print-button"]Print this section[/print_post]
Results
<a class="print-button" href="#" id="print" onclick="jQuery('.main-content .page-elements').print();">Print this section</a>
This example will display the link will have the class print-button for styling. |
Browser Compatibility: The print functionality is dependent on the user’s browser. Some browsers may not support printing specific sections of a page.
Custom Styling: Use the
class attribute to apply custom styles to the print button..