Discussion:
Remove only certain shortcodes
Dino Termini
2014-03-24 16:56:12 UTC
Permalink
Hi,

I have a website with pages using various shortcodes. When I run a
search, the search result page uses the_excerpt, and it displays an
unformatted output of those shortcodes. How can I disable them so that
they don't appear in the search result page? Is there a way to target
specific shortcodes?

Thanks,
Dino
Thomas Belknap
2014-03-24 16:58:23 UTC
Permalink
https://codex.wordpress.org/Function_Reference/remove_shortcode

Tom Belknap
Owner/Editor, DragonFlyEye.Net
Over Drinks columnist, (585) Magazine <http://585mag.com>
Join me:

- *Inbox:* http://dragonflyeye.net/subscribe
- *Web*: http://dragonflyeye.net/
- *Facebook*: https://www.facebook.com/DragonFlyEye.Net
- *Twitter*: https://twitter.com/dragonflyeye
- *Google*: https://plus.google.com/u/1/103251482414903117843/posts
Hi,
I have a website with pages using various shortcodes. When I run a search,
the search result page uses the_excerpt, and it displays an unformatted
output of those shortcodes. How can I disable them so that they don't
appear in the search result page? Is there a way to target specific
shortcodes?
Thanks,
Dino
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Nicholas Ciske
2014-03-24 16:59:46 UTC
Permalink
http://wordpress.org/support/topic/stripping-shortcodes-keeping-the-content?replies=16

_________________________
Nick Ciske
http://thoughtrefinery.com/
@nciske
Dino Termini
2014-03-24 17:06:51 UTC
Permalink
Nicholas, you saved my day ;)

In case other people are interested in the solution:

|$exclude_codes = 'shortcode_to_keep_1|keep_this_shortcode|another_shortcode_to_keep';

$the_content = get_the_content();
$the_content= preg_replace("~(?:\[/?)(?!(?:$exclude_codes))[^/\]]+/?\]~s", '', $the_content); # strip shortcodes, keep shortcode content
|


Thank you
Post by Nicholas Ciske
http://wordpress.org/support/topic/stripping-shortcodes-keeping-the-content?replies=16
Nashwan Doaqan
2014-03-24 17:13:52 UTC
Permalink
hmmm.. I am using Moody Shortcodes for this kind of things:
https://wordpress.org/plugins/wp-moody-shortcodes/
Post by Dino Termini
Nicholas, you saved my day ;)
|$exclude_codes = 'shortcode_to_keep_1|keep_this_shortcode|another_
shortcode_to_keep';
$the_content = get_the_content();
$the_content= preg_replace("~(?:\[/?)(?!(?:$exclude_codes))[^/\]]+/?\]~s",
'', $the_content); # strip shortcodes, keep shortcode content
|
Thank you
Post by Nicholas Ciske
http://wordpress.org/support/topic/stripping-shortcodes-
keeping-the-content?replies=16
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...