Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a few extra custom fields added into a user's profile and output them in several places within the frontend. One thing I want to do is add some of those custom fields into the WordPress Feed as RSS elements. As an example, I know that the Author Display Name is output by default but also want to add their Twitter handle into the feed too.

Anyone know a solution to this? Thanks

share|improve this question

1 Answer 1

Check out either the the_content_feed and the_excerpt_rss filters or use the regular content and excerpt filters with the is_feed conditional function.

The following should get you on the right track:

function wpse_140401_add_to_feed( $content )
{
    $twitter_handle = /* grab handle */;

    if ( is_feed() ) {
        $content .= '<p>' . $twitter_handle . '</p>';
    }

    return $content;
}
add_filter( 'the_excerpt_rss', 'wpse_140401_add_to_feed' );
add_filter( 'the_content_feed', 'wpse_140401_add_to_feed' );

Note that given the fact that the above uses filters applied to feeds only, the conditional isn't strictly necessary.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.