[wp-hackers] nested shortcode

Daiv Mowbray daiv at daivmowbray.com
Wed Jan 21 09:48:26 GMT 2009


Ok thanx, Otto,

I didn't realize that there are 2 types of response to a shortcode.
I knew there's various manners to add it,
I wanted to simply add the tag [addmyclass]
and activate a search replace in my plugin to add the class="myclass"  
to any image in the post.

Easier for the user to add [addmyclass] than to review in code all  
images and
have to add class="myclass".

I guess that wrapping a post in [addmyclass]post[/addmyclass] is an  
option.


Also, I had been trying to use : do_shortcode($content)
as recommended in the docs, as the shortcode search and replace function
only does a single pass of the post content.

I was getting results with unprocessed shortcode, namely the [caption].
Perhaps my problem lay elsewhere.

Daiv

On Jan 21, 2009, at 7:37 AM, Otto wrote:
> Why are you returning do_shortcode($content)? It's already doing the
> shortcodes, you don't need to have it run through them again. Just
> return the new $content.




On Jan 21, 2009, at 7:41 AM, Otto wrote:

> Also, remember that there's two types of shortcodes.
>
> 1. Something like [gallery], which simply gets replaced with a bunch  
> of content.
> 2. Something like [caption]<img whatever>[/caption], which adds stuff
> to the existing content.
>
> If you're simply adding [myclass] in the post, then I your $content
> will be empty, since you're not surrounding anything, thus using the
> first type of shortcode. Shortcodes only get the content that they
> enclose. Not the whole post.


----------
Daiv Mowbray
daiv at daivmowbray.com
----------




More information about the wp-hackers mailing list