Skip to content

Instantly share code, notes, and snippets.

@danemorgan
Created January 24, 2017 23:20
Show Gist options
  • Save danemorgan/888adeb21f8831df390284bb98216495 to your computer and use it in GitHub Desktop.
Save danemorgan/888adeb21f8831df390284bb98216495 to your computer and use it in GitHub Desktop.
Find shortcodes in WordPress Posts
<?php
// Regular Expression to match [shortcodes].
$regex = '(\[title(.*?)?\](.+?)?\[\/title\])';
// Store them in an array
preg_match( $regex, $content, $action_matches );
// Remove them.
preg_replace( $regex, '', $content );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment