I have the following PHP code below that I would like to add to the category feed in WordPress.
<?php if(get_the_post_thumbnail()): ?>
<featured-item><?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?></featured-item>
<?php endif; ?>
I know that I can edit feed-rss2.php
to add it into the general feed. But the same code isn’t allowing me to add it to the category view of the same RSS feed.
Where do I place this code for the generated RSS feed?
FYI, you should never hack the WordPress core files. Instead, WordPress provides the handy
rss2_item
action hook. All we need to do is check if we’re on a category feed or not: