As of print-o-matic version 2.0.1 the ability to use class to target a print element in external print triggers has been added. Basically it works the same as using the data-print_target attribute but instead uses a unique classname in the format of printtarget-<target_id>.
Create a target element. The element below is a div with an id of ‘my_print_target’:
<div id="my_print_target">This is the print target wrapped in a div with an element of 'my_print_target' as explained above</div>
This is the print target wrapped in a div with an element of ‘my_print_target’ as explained above
Add an external trigger using the new class-trigger method. We’ll use a simple button like so:
The checkbox must have an ID of ppm_odnp (because print-pro-matic optional do not print is a bit long). The value is the optional do not print selector, so .logo is for items with a class of ‘logo’, while #logo is an item with an id of ‘logo’.
Now WordPress will look for something like /?print_view=true at the end of any url.
Next step is to tell print-pro-matic to use the current page with the print_view query variable tacked on the back as the target url. Simply set the url attribute using the %print_view% placeholder as its value:
[print-me id="some_id" url="%print_view%"/]
Finally we need to check for this print_view query var and either a) use a custom print-only template file or b) modify the current page template to switch to a print-only view.
Redirect to Print-Only Template
If a print-only template exists simply redirect to this template file by adding the following code to the child-theme’s function.php file:
Here is an example of using Print-O-Matic to print a WordPress Chart using wp-charts.