WooCommerce Pay Per Post Premium modification, thumbnails and expired label.

I started using Matt’s WooCommerce Pay Per Post (free version at link, need premium for this modification) plugin for WordPress back in August of 2018, I found it to be a great tool to easily sell access to posts. With this installed you can setup a product and then create a post, page, or other custom post type and select the product that needs purchased to enable access to view the post. You could use this to sell photo posts, videos, how to instructional, or anything people want to view. The free version of the PPP plugin is limited in its function to basically just setup and sell access that a user would have access to for however long the post remains up. With the premium version you have much more custom settings and expiry options. This plugin does lock the post so you can only view if you have paid.

I recently asked Matt if he could put a “expiration status” attribute, this was so I could show my customers what posts were EXPIRED using the purchased shortcode list that comes with the plugin. This just makes it easier to see what posts are still active in the growing list, many of my customers have 50+ PPP posts paid for. The normal version will just have a list of all your purchased posts and no way to easily see whats expired or active. You can even use this handy function to create your own active only purchased list or even possible custom post navigation for PPP. A recent update added the option to show the purchased list in the WooCommerce My Account tab, this modification will change the appearance of that too.

You need to have WooCommerce installed and setup to use this, and this modification is designed to work only on the Premium version. You can edit out the expired access check and EXPIRED message to just get thumbnails that can be clicked on modification for the free version. This can be styled better but this is just a plain sample, I saw a few people ask about this on the forums but no good working version was posted so here is mine.

This little modification just adds a 150×150 thumbnail that can be clicked on and label at the end of the post title that will show EXPIRED if the post has expired for viewing in the purchased list.

In the plugin files you need to make a copy of the file to modify yourwebsite.com/wp-content/plugins/woocommerce-pay-per-post-premium/public/partials/shortcode-purchased.php

In the file at line 26 you will delete the original line and replace it with the code below, in my edit I do remove the <li> list order code on line 25 and 27. To keep this modification during updates add this file into a child theme like this example yourwebsite.com/wp-content/themes/child-theme/woocommerce-pay-per-post/shortcode-purchased.php . Notice even if you have the premium version you still use the normal folder name in the child theme and not -premium like in the premium version plugin folder.

Original lines 25-27 below, these will be replaced.

<li>
  <a href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>"><?php echo esc_html( $post->post_title ); ?></a>
</li>

Copy this code below and replace lines 25-27 with it. Modified is now just one line 25 below.

<a href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>"><?php echo get_the_post_thumbnail( $post->ID, array(150,150) ); ?></a> <a href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>"><?php echo esc_html( $post->post_title ); ?><?php if($post->expiration_status): ?> <span><strong>EXPIRED</strong></span> <?php endif; ?><br></a>

Below after you have edited line 26 it should look like my template, I removed the list order code in my template fyi so code is now line 25.

Below what the modified purchased shortcode list looks like with a post that has expired but has been purchased before, very plain. I keep my shortcodes in a gutenberg accordion to keep the page cleaner.

Leave a Comment