WordPress Code Snippets

A fresh mix of code snippets and tutorials

WordPress Conditional Shortcodes via Ajax


This example builds from the conditional do_shortcode technique to evaluate shortcodes during Ajax requests.

The following example illustrates use of get_shortcode_regex() to check if Ajax-loaded content includes the target shortcode, [ses_pro]. If it exists, we parse the shortcode attributes for later use in our script.

Here we check if WordPress is DOING_AJAX before using shortcode_parse_atts() to get an array of all shortcode attributes and their associated values. This is another snippet from my plugin, SES Pro (Simple Email Signups).


Learn more

WordPress Themes In Depth

Show Support

Like our new Facebook Page to show support!