1

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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