[wp-hackers] shortcodes, BR tags and feed/XML-RPC interfaces

// ravi ravi-lists at g8o.net
Fri Sep 4 15:27:50 UTC 2009


Hello all,

I wrote a quick and dirty shortcode as part of my WP theme that lets  
me use a multi-line shortcode:

[qfgallery]
URL-to-image-1
URL-to-image-2
[/qfgallery]

to generate a custom image gallery using FancyBox.

Despite what this thread (http://bit.ly/u2kvv) seems to suggests (or  
perhaps I am reading it wrong), it seems that in my shortcode handler,  
I get <br/> tags after each line in $content. I am parsing it out but  
I am curious if this is expected behaviour.

Also, one shortcoming of my quick and dirty trick seems to be that  
though my splendid FancyBox gallery is rendered correctly in the  
browser, when the content is pulled via the feed or XML-RPC the  
shortcode is left as-is -- which is understandable I guess since the  
theme only applies to browser rendering. Is this correct? i.e., there  
is no way for me, in my theme code, to enable shortcode expansion for  
post content for feeds and XML-RPC?

One way to overcome this may be to add an action or filter, which  
would entail (if I am getting it right) the creation of a plugin. I do  
not want the plugin to modify the content as it is saved i.e., I do  
not want it to hook into the post editing function. That would cause  
the shortcode to be expanded/replaced on saving, preventing future  
edits. I could instead, I hope, add a filter that would kick in when  
the content is accessed (irrespective of the reason/means of access,  
whether it be for rendering in browser, or for feed or XML-RPC).

Any suggestions, comments or advice would be great. Thank you,

	--ravi



More information about the wp-hackers mailing list