Forked from strangerstudios/pmpro_loadTemplate_example.php
Last active
April 3, 2021 04:07
-
-
Save ideadude/bebd85e897b487d6ed9f8371bff02a8b to your computer and use it in GitHub Desktop.
Example of a shortcode that uses pmpro_loadTemplate to grab it's template file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
[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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: https://www.paidmembershipspro.com/new-method-load-custom-templates-pmpro-generated-pages-system-generated-emails/