Get shortcode attribute outside of WordPress
Don’t try to parse the shortcodes and then regex the HTML. Use get_shortcode_regex() to parse the raw post content: $content = $content_post->post_content; preg_match_all(“/$pattern/”,$content,$matches); Then crawl $matches to find your shortcode data. Use shortcode_parse_atts($matches[3][0]) (note $matches[3][0] to give the first element within the matched shortcode’s attributes) to pull apart the attribute string. Reference: https://wordpress.stackexchange.com/a/73461/21376