Created
August 22, 2020 02:49
-
-
Save xnau/95d81c5e2479110f02ae32cbd577cade to your computer and use it in GitHub Desktop.
Demonstrates how to let Participants Database know there is a shortcode on a page (see comments for full explanation)
This file contains 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
// check for a specific post ID, then fire the action if it matches | |
add_action( 'wp', function () { | |
global $post; | |
if ( $post->ID == 9627 ) { | |
do_action( 'pdb-shortcode_present'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Participants Database avoids loading it's content and assets on pages that don't have Participants Database content. Since the plugin is shortcode-based, it does this by inspecting the content of the current page and fires an action (pdb-shortcode_present) if a Participants Database shortcode is on the page.
With some types if shortcode placement (such as in a widget), the shortcode isn't actually in the page content, so the plugin doesn't know to load the assets. This code snippet provides a way to let Participants Database know it should load its assets on a particular page.
In the example, the page has an ID of 9727. Change that to be the post ID of the page you need the trigger the asset load on.