This is working for me
$shortcode="book";
$pattern = get_shortcode_regex();
// if shortcode 'book' exists
if ( preg_match_all( "https://wordpress.stackexchange.com/". $pattern .'/s', $post->post_content, $matches )
&& array_key_exists( 2, $matches )
&& in_array( $shortcode, $matches[2] ) ) {
$shortcode_atts = array_keys($matches[2], $shortcode);
// if shortcode has attributes
if (!empty($shortcode_atts)) {
foreach($shortcode_atts as $att) {
preg_match('/id="(\d+)"https://wordpress.stackexchange.com/", $matches[3][$att], $book_id);
// fill the id into main array
$book_ids[] = $book_id[1];
}
}
...
Related Posts:
- How can I return shortcode output to the top of the content?
- apply_filters(‘the_content’, $content) vs do_shortcode($content)
- How to show page content in feed?
- How to get shortcode’s input values inside a filter?
- Filter specific shortcode output?
- Where to hook into post content?
- Insert Custom HTML After Shortcode
- Is there a way to add another row to the tinyMCE kitchen sink toggle?
- add_filter and changing output captions of image gallery
- How to add attribute to output with wp_video_shortcode add_filter
- Change default settings used by gallery shortcode
- Shortcodes not resolved in AJAX call response
- Ajax, filters and shortcodes
- Format content value from DB outside of WordPress filters
- Use content custom filter for all shortcodes
- How to link current user to their author page through shortcodes
- filter title from shortcode
- how to remove filter from wordpress shortcode output
- Error when overriding only some audio shortcode HTML output
- Hide content editor for posts after approriate date
- How to use shortcode attribute in separate function
- Applying custom filter instead of the_content doesn’t render embeds
- apply_filters(‘the_content’) – make it ignore shortcodes?
- Empty string supplied as input when parsing content
- Shortcodes — Using add_action, add_filter in the shortcode
- How to filter post content and force every link () made in blocks to return urldecode() with readable value?
- Remove Content Filter
- How to pass variables to custom filter from multiple functions
- How to filter backend post list showing only posts having a shortcode
- the_excerpt filter doesn’t work as expected
- run shortcode in excerpt of single custom post type
- Filter everything from content except output of a shortcode
- Something is filtering my shortcodes… Can’t figure out what
- Trimming a custom field to a length
- How to use do_shortcode_tag to modify the output of a shortcode?
- Shortcodes within the sidebar text/html widget: How to preserve the raw HTML output of the shortcode?
- How to change dynamically page title according to variable data?
- How can I filter tag_description()?
- WordPress removing slashes from shortcode output
- How to remove shortcode(s) from WYSIWYG Page editor for Non Admins
- add after content don’t work
- Shortcode / plugin with custom (flexible) output
- Filter Shortcodes when using get_page
- Parse a shortcode differently based on on what it’s nested in
- Need to return shortcode text instead of the output
- add_filter to the_content after apply_filters
- post_orderby filter breaks function
- the_content getting current page content instead specified ID
- Override wordpress audio playlist
- how to use substr with get_the_content()
- How to wrap pattern-matches from the_content in [wiki]-shortcode tags
- Add Index to Item in WordPress Gallery
- create a shortcode with acf including a filter
- How to take shortcode and content separately from a page?
- Replace Text with hyperlinks
- Auto-generated excerpt with shortcode and read more button/text link
- shortcode function outputs multiple anchor tags
- apply_filters to $GLOBALS
- Change shortcode output (filter?)
- Problem in outputting shortcode
- Is it possible to include the add_filter() function within a shortcode function
- Activate short codes for all post queries?
- Problem with shortcodes in external file
- How can I display wp_link_pages before a shortcode, if it is used, or display after content?
- add_filter(‘the_content’, ‘method’) does not trigger my custom method
- AAPF Filter group is not in widget section
- apply_filters to content but ignore shortcodes
- Custom registration field to SQL database
- Save something to global var in add_filter
- WordPress URL rewrite problem
- wp_get_attachment_link filter not working
- Add class to all parent elements inside the_content
- Updating User Profile on Registration
- Is this correct usage of filters in WordPress [closed]
- How would I remove an inline googleAPI font script in the the parent theme header.php?
- Loading a sidebar on an Ajax call
- the_excerpt() does not work with has_excerpt()?
- Overwriting a Shortcode
- Is there a way to overwrite a filter used in canonical.php?
- can’t output gray scaled image I’ve created using add_image_size
- Customize register form page with add_action or apply_filter
- filter on the_content stopped working when I updated to WP 3.6.1
- Replace Paid Shipping Method With Free Shipping Method WooCommerce [duplicate]
- get_the_excerpt on mobile still displays continue reading
- How to reset/remove added filters ‘posts_join’ and ‘posts_orderby’ after the loop is completed?
- Strip shortcode from excerpt [duplicate]
- Wrapping Featured Image on Add/Edit Page in div?
- remove_filter excerpt_more from a plugin class
- Date filter for post query not filtering results when variable outside the function
- How do I remove certain HTML elements with specific classes from the feed?
- Passing variable from filter
- How to turn this customized core function into a filter/action in functions.php?
- Turn wp_tag_cloud into a front-end filter
- Custom excerpt_more filter not working when tag is present
- Adding an orderby filter, casting postmeta with multiple keys
- How we make the filter for fornt end user
- Filter image and text from post format
- Identify admin/logout and more filters
- Add Default WordPress Formatting To Data From External SQL Tables?
- Sanitizing a custom query’s clauses