Custom Print Templates for Print-Pro-Matic

Note: This post assumes a basic understanding of WordPress templates and that a child-theme is being used.

To create a custom print template we first need to define a query var to trigger the template.
Add the following to the child-theme’s function.php file:

function printpromatic_query_var( $vars ) {
	$vars[] = 'print_view';
	return $vars;
add_filter( 'query_vars', 'printpromatic_query_var' );

Now WordPress will look for something like /?print_view=true at the end of any url.

Next step is to a) define a unique ID for the print trigger and b) tell print-pro-matic to use the current page with the print_view query variable tacked on the url. Do this by setting 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:

function printpro_print_template($original_template) {
    if ( get_query_var( 'print_view' ) ) {
		$new_template = locate_template( array( 'print-template.php' ) );
        return $new_template;
	return $original_template;
add_filter( 'template_include', 'printpro_print_template' );

This could be expanded further to support multiple print-only templates based on a value passed to print_view:

[print-me id="monkey_id" url="%print_view=monkey%" title="print monkey"/]
[print-me id="donkey_id" url="%print_view=donkey%" title="print donkey"/]
print monkey
print donkey

This would require that our function be modified to use the correct print template based on the print_view query var:

function printpro_print_template($original_template) {
    $print_view = get_query_var( 'print_view' );
    if ( !empty( $print_view ) ) {
        if($print_view == 'monkey'){
            $new_template = locate_template( array( 'print-template-monkey.php' ) );
        else if ( get_query_var( 'print_view' ) == 'donkey' ){
	    $new_template = locate_template( array( 'print-template-donkey.php' ) );
            return $new_template;
    return $original_template;
add_filter( 'template_include', 'printpro_print_template' );

Modify the Existing Template

This method involves modifying the current page template to change what it displays based on the presence of the print_view query var.

In the page template being used, we need to check if the query_var is present:

$print_view = get_query_var( 'print_view' );

Now we need to simply wrap the existing template elements in an if statement:

if( empty($print_view) ){
//print only

Archive-Pro-Matic Display Multiple Categories

As of version 1.1.2, multiple categories can be selected using the cat_id attribute. Simply provide a comma separated string of the category ID’s to include. Use a negative ID to omit multiple categories.

For example to include a yearly archive of posts with both the categories of ‘Archive-Pro-Matic’ (ID 55) and ‘collapse-pro-matic’ (ID 43) the shortcode would be:

[archives type="yearly" cat_id="55,43"/]
[archives type="monthly" cat_id="55,43" limit="10" /]

Collapse-Pro-Matic Spacing

this is a monkey

This is some text

Here is a headline

100-1 First thing
100-2 Second Thing
a. First Sub thing
b. Second sub thing
100-3 Third Thing
100-4 Forth Thing
100-5 Fifth Thing
I am bold.
Some info:
Here is some info that explains more about thing five.
100-6 Sixth Thing
100-7 Seventh Thing

Numbered List Items

<ul class="numbers">
    <li data-pos="2">one</li>
    <li data-pos="2">two
            <li data-pos="2"></li>
            <li data-pos="2">two.two</li>
            <li data-pos="2">two.three</li>
    • one


    • two




        • two.two


        • two.three




    • three




        • three.two


            • – this is a much longer piece of text that will wrap around and should display how the padding and offset of the numbering works with a longer text.


            • three.two.two






  • four


ul.numbers {
    counter-reset: levelone;
    list-style: none;

ul.numbers > li {
    counter-increment: levelone;

ul.numbers > li[data-pos]:before {
    content: attr(data-pos) "." counters(levelone, ".") ". ";

ul.numbers ul {
    counter-reset: leveltwo;
    list-style: none;

ul.numbers ul > li {
    counter-increment: leveltwo;

ul.numbers ul > li[data-pos]:before {
    content: attr(data-pos) "." counters(levelone, ".") "." counters(leveltwo, ".") ". ";

ul.numbers ul ul {
    counter-reset: levelthree;
    list-style: none;

ul.numbers ul ul > li {
    counter-increment: levelthree;

ul.numbers ul ul > li[data-pos]:before {
    content: attr(data-pos) "." counters(levelone, ".") "." counters(leveltwo, ".") "." counters(levelthree, ".") ". ";