Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of a shortcode that uses pmpro_loadTemplate to grab it's template file.
[my_pmpro_addon] shortcode.
function my_pmpro_addon_shortcode() {
//load template
$content = pmpro_loadTemplate( 'my_pmpro_addon' ); //will look for /wp-content/themes/your-theme/paid-memberships-pro/pages/my_pmpro_addon.php
//maybe tweak the content a bit
//return it
return $content;
add_shortcode('my_pmpro_addon', 'my_pmpro_addon_shortcode');
Add a directory from this plugin folder to search when using pmpro_loadTemplate
function my_pmpro_addon_pmpro_pages_custom_template_path( $default_templates, $page_name, $type, $where, $ext ) {
$default_templates[] = dirname(__FILE__) . '/pages/' . $page_name . '.' . $ext;
return $default_templates;
add_filter('pmpro_pages_custom_template_path', 'my_pmpro_addon_pmpro_pages_custom_template_path', 10, 5);

This comment has been minimized.

Copy link

@laurenhagan0306 laurenhagan0306 commented Apr 3, 2021

This recipe is included in the blog post on "How to Load a Custom Template for Membership Pages or System-Generated Emails" at Paid Memberships Pro here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment