function shortcode_only_wpse_96114($content) {
$regex = get_shortcode_regex();
preg_match_all("https://wordpress.stackexchange.com/".$regex."https://wordpress.stackexchange.com/",$content,$matches);
if (!empty($matches[0])) {
$content = do_shortcode(implode(' ',$matches[0]));
}
return $content;
}
add_filter('the_content','shortcode_only_wpse_96114',1);
That should check for any registered shortcodes and if present completely replace the post content with the output of the shortcode(s), removing any other content. If no shortcodes are found the post content gets returned as normal.
Barely tested. Possibly buggy. Caveat emptor. No refunds.
Reference
http://codex.wordpress.org/Function_Reference/get_shortcode_regex
Related Posts:
- apply_filters(‘the_content’, $content) vs do_shortcode($content)
- How to get shortcode’s input values inside a filter?
- Filter specific shortcode output?
- 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
- Search content for shortcodes and get parameters
- 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
- How to use shortcode attribute in separate function
- Shortcodes — Using add_action, add_filter in the shortcode
- How to pass variables to custom filter from multiple functions
- How to filter backend post list showing only posts having a shortcode
- How can I return shortcode output to the top of the content?
- the_excerpt filter doesn’t work as expected
- run shortcode in excerpt of single custom post type
- Something is filtering my shortcodes… Can’t figure out what
- 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
- 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 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?
- 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?)
- 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?
- Disable emojicons introduced with WP 4.2
- add_action(), add_filter() before or after function
- wp_headers vs send_headers. When to use each?
- Filter any HTTP request URI?
- How to appending to the_content using add_filter with custom post type?
- Why is javascript allowed in my post content?
- Adding a filter to qTranslate to change display of language chooser
- Check if a filter or function has been already been called
- Custom Rewrite Rules Not Sticking
- Customizing WordPress the_title with add_filter
- How can I send data to admin-ajax via JS Fetch?
- Disable resizing of gif when uploaded
- Detecting Embed URLs Within post_content
- add_filter on “the_excerpt” only works when post does not have excerpt
- How can I display image metadata?
- How to prepend text to the_content, but after img/shortcode
- Can’t change the title tag with wp_title filter
- How to filter ‘post_gallery’ after all other filters/plugins etc
- Can’t get wp_title filter working in twenty sixteen child theme
- add_action uses ‘echo’ add_filter uses ‘return’, why?
- Filter oembeds tags to modify iframe attributes
- Removing labels and tag on WordPress’s default login form
- How to add data- attribute to tag
- How to trigger the core WPLANG to make automatically set a language when the theme is activated? [duplicate]
- Making a class available via actions filters
- How to check a filter are applied
- How do I add a listbox to the TinyMCE editor?
- How to remove google font in WordPress for only single page?
- How do I filter get_the_excerpt() but keep all of its functionality intact?
- Remove tags from the kses filter
- Overwrite default WordPress wording
- How to add a class to Tag cloud widget link?
- How to get all the predefined do_action() calls from an active theme
- Is there a get_post(s) filter that can alter/replace the output completely?
- WooCommerce Variable Product Price – Where is “From” text generated from?
- Using ‘posts_where’ on a query with a custom field
- How to add numeric slug for child page in WordPress 5.9?
- add_filter does not work as expected
- Custom Login Errors and variables I can use
- Filter taxonomy admin pagination
- ‘the_content’ filter removing html tags from post content
- Custom view counts not updating correctly
- Using wp_handle_upload() to Direct Specific Path by Using $overrides
- I can not include page to wordpress function add_filter, the_content
- How to create Woocommerce Product Filter Widget [closed]
- Filter to shorten column content on edit-tags.php
- Create Search Form to Filter Through Terms
- Formatting get_post content doesn’t allow JS content to function properly
- Proper after_setup_theme and wp_head cleanup