Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Google Calendar Events: How to properly enqueue scripts and styles in a page template when using do_shortcode().
<?php
/**
Template Name: Stripe Checkout PRO page template
*/
// Enqueue Google Calendar Events CSS.
wp_enqueue_style( 'google-calendar-events-public' );
// Enqueue Google Calendar Events JS.
wp_enqueue_script( 'google-calendar-events-public' );
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'content', 'page' );
// End the loop.
endwhile;
?>
<div>
<?php echo do_shortcode( '[gcal id="123"]' ); ?>
</div>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment