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?
- How to remove a filter that is an anonymous object?
- How to add defer=”defer” tag in plugin javascripts?
- No filter of code on switch from html to visual editor, how?
- How to modify posts_where filter only for the search query
- How to wrap oEmbed-embedded video in DIV tags inside the_content?
- How to add filter with 2 args?
- WordPress Internal @ Mentions
- Changing text within the Block Editor
- Is it possible to Hook/Filters Attachment Creation?
- Apply the_title filter to post titles AND backend auto social-sharing plugin, but not nav menu
- How to hook some Unicode texts into calendar widget safely?
- How to add attributes to tag when template cannot be directly modified
- Edit pagination text in the get_the_posts_pagination function
- How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
- When adding buttons to the tinyMCE editor, how do I make them wrap to the next line and/or display in the “Kitchen Sink” area?
- How to change the order of HTML output of a core block?
- How to add ‘total’ value to custom column title on the posts list page
- Is it possible to use multiple spaces in title?
- Create Page Template by hook programatically in Functions.php in WP 5.8.1
- Filter out comments with certain meta key/s in the admin backend
- HTML and custom field variable, inside variable
- WordPress custom admin notice still displays after wp_insert_post_data validation
- Run posts_where and posts_join only on the main query
- Trimming a custom field to a length
- How to add a filter to the get_body_class function?
- How to hide/remove GhostKit component panel in gutenberg block inspector
- when use function the_content break
- Filter page title (displayed in browser tab) of wp-login
- Adding html banner to posts
- How can I get the default content of WordPress post?
- How do I hide tinymce within the edit screen of a particular page
- How does wordpress add ‘style’ attribute to element
- How do I safely force get_theme_mod() to use a defined get_option(“stylesheet”) value?
- Filter “Your latest posts”
- Is it better to use a constant or apply_filter?
- Hooked into wp_get_attachment_caption to add content to the default description; not working for jetpack slideshow. Why?
- Removing menus from users other than the administrator
- Add option to query string before get_posts() is called on archive.php
- Modify wp headers on specific page
- How can I add a prefix to titles displayed in sidebar using function.php?
- List all image sizes still getting disabled sizes
- Why this remove empty paragraphs from the_content does not works?
- Take filter from multiple functions
- Adding to an array & passing it through do_action/apply_filters
- Custom excerpt_more filter not working when tag is present
- Taxonomy search filters
- Modify the third (context) parameter in a filter?
- Query Multiple Filters, one with Meta
- How to remove a filter that is an object method?