Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Last active September 20, 2018 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save strangerstudios/6b2ab3d39e34476d8d3dd76833d9b14a to your computer and use it in GitHub Desktop.
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.
<?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');
@ideadude
Copy link

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.

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