Get the link for RSS item to display in feed

function wpbeginner_postrss($content) {
global $wp_query;
$postid = $wp_query->post->ID;
if(is_feed()) {
$coolcustom = get_field(‘fl_quote’);
$link = get_post_meta( get_the_ID(), ‘link’, true );
$content = ‘<div>’ .$coolcustom. ‘</div></br><div>This post first appeared on My site – read more at <a href=”‘. esc_url($link) .'”>’ . get_the_title_rss(). ‘&nbsp;&rarr;</a>’;
}
return $content;
}
add_filter(‘the_excerpt_rss’, ‘wpbeginner_postrss’);
add_filter(‘the_content’, ‘wpbeginner_postrss’);

For some reason the link is displayed empty inside the RSS feed. Is there something wrong with the way I obtain the $link ?

Read more here:: Get the link for RSS item to display in feed

Leave a Reply

Your email address will not be published. Required fields are marked *