Last active
September 20, 2018 18:21
-
-
Save strangerstudios/6b2ab3d39e34476d8d3dd76833d9b14a 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) { | |
$default_templates = array_merge(array(dirname(__FILE__) . '/pages/'), $default_templates); | |
return $default_templates; | |
} | |
add_filter('pmpro_pages_custom_template_path', 'my_pmpro_addon_pmpro_pages_custom_template_path'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The updated version of this gist can be found here: https://gist.github.com/ideadude/bebd85e897b487d6ed9f8371bff02a8b
We can no longer edit gists owned by the strangerstudios user so had to fork it.