Remove only certain shortcodes

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Remove only certain shortcodes

Dino Termini
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
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Remove only certain shortcodes

Thomas Belknap
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




On Mon, Mar 24, 2014 at 12:56 PM, Dino Termini <[hidden email]>wrote:

> 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
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Remove only certain shortcodes

Nicholas Ciske-2
Reply | Threaded
Open this post in threaded view
|

Re: Remove only certain shortcodes

Dino Termini
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

On 3/24/14, 12:59 PM, Nicholas Ciske wrote:
> http://wordpress.org/support/topic/stripping-shortcodes-keeping-the-content?replies=16
>
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Remove only certain shortcodes

Nashwan Doaqan
hmmm.. I am using Moody Shortcodes for this kind of things:
https://wordpress.org/plugins/wp-moody-shortcodes/


On 24 March 2014 20:06, Dino Termini <[hidden email]> wrote:

> 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
>
> On 3/24/14, 12:59 PM, Nicholas Ciske wrote:
>
>> http://wordpress.org/support/topic/stripping-shortcodes-
>> keeping-the-content?replies=16
>>
>>
>>  _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers