[wp-hackers] Linking stylesheet to RSS feeds

Peter Westwood peter.westwood at ftwr.co.uk
Wed Jun 17 07:06:01 GMT 2009


On 17 Jun 2009, at 07:04, RePost wrote:

> Austin Matzko wrote:
>> On Tue, Jun 16, 2009 at 2:46 AM, RePost <repost_08 at yahoo.com> wrote:
>>
>>> I'd like to style my WordPress feed. Can I style the feed? How can  
>>> I style the feed? Inline, you say? How can I add inline styles to  
>>> my feed?
>>>
>>
>> You could make inline markup changes to your feed by conditionally
>> attaching a callback filter to "the_content", etc., whenever  
>> is_feed()
>> returns true:
>>
>> if ( is_feed() ) {
>>   add_filter('the_content', 'my_rss_markup_replace');
>> }
>>
>> [snip]
>>
>> function my_rss_markup_replace($content = '')
>> {
>>   return preg_replace('#(<img[^>]*>)#', '<div
>> style="margin:10px;">$1</div>', $content);
>> }
>> _______________________________________________
>

Looking quickly at that code I have a feeling it is safer to always  
add the filter and place the is_feed() check inside the function  
attached to the filter.

When the plugin file is included is_feed() will always return false as  
the query hasn't run yet.

westi
-- 
Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5



More information about the wp-hackers mailing list