Over on my photo blog I have a template that uses WordPress’ meta tags to store images, rather than requiring me to insert them in the usual way. This is great because it means the image can be displayed separately to the post’s text, but also means the RSS feed and LiveJournal cross-post (LJXP) views contain just the post’s text and no image. The RSS feed and LJXP parts of WordPress use The Loop and the_content() to extract data from WordPress, totally ignoring any meta tags in the post.
This makes it somewhat useless for a photo blog.
I have hacked both the RSS feed mechanism of WordPress, and the LJXP plugin so that they show the contents of a meta-tag called ‘image’ as part of the page content. These are fairly dirty hacks which are specific to the template I’m using, but others may find the information useful (and so will I when I next upgrade WordPress and wonder why everything has broken
)
Modifying the RSS feed
This is the simplest hack. Simply open up wp-includes/feed-rss2.php and find the line
<?php if ( strlen( $post->post_content ) > 0 ) : ?> <content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded>
Modify the second line to be like this
<content:encoded><![CDATA[<?php the_content() ?><br/><img src="<?php echo get_post_meta ($post->ID, 'image', true);?>" />]]> </content:encoded>
And then save and refresh the RSS feed in your reader (this may take a while with something like Google Reader. You can force it by editing one of your posts and subtly altering the post date by a second or so).
Modifying the Livejournal Crosspost Plugin
This requires a bit more trickery. We’re going to hack the plugin so that it understands a new custom header/footer ‘tag’ and also define a custom footer with our new tag inside. I chose this because it will be easier to repair when the LJXP plugin next gets updated and my changes wiped out.
Edit the file wp-content/plugins/lj-xp/lj-xp.php
Find these two lines
$find = array('[blog_name]', '[blog_link]', '[permalink]',
'[comments_link]', '[comments_count]', '[tags]', '[categories]');
$replace = array($blogName, get_settings('home'),
get_permalink($post_id), get_permalink($post_id).'#comments',
lj_comments($post_id), $htags, $hcats);
And just modify them like this
$find = array('[blog_name]', '[blog_link]', '[permalink]',
'[comments_link]', '[comments_count]', '[tags]', '[categories]',
'[image]');
$replace = array($blogName, get_settings('home'),
get_permalink($post_id), get_permalink($post_id).'#comments',
lj_comments($post_id), $htags, $hcats,
get_post_meta($post_id, 'image', true));
- Now go into the WordPress dashboard, and click on “Livejournal” under Settings.
- Toggle the “Bottom of Post” radio button in the Set blog name for crosspost header/footer section
- In the Custom crosspost header/footer box put something similar to this
<a href="[permalink]"><img src="[image]" alt="Gallery image" /></a> <br/> Originally posted from <a href="[blog_link]">[blog_name]</a>. Please leave comments <a href="[comments_link]">over there</a>.
And then press Update Options. You may see an error message, it doesn’t appear to be a fatal one. Make a test post to your blog to test things, or edit and republish an existing post to see if it works.

