0
function wpbeginner_postrss($content) {
global $wp_query;
$postid = $wp_query->post->ID;
if(is_feed()) {
$coolcustom = get_field('fl_quote');
$link = the_permalink_rss(); 
$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 ?

0

The the_permalink_rss() is echoing it's content not returning it.

If we look at the source of this function: https://developer.wordpress.org/reference/functions/the_permalink_rss/

We can just copy what it's doing, as it's a simple function.

$link = esc_url( apply_filters( 'the_permalink_rss', get_permalink() ) );

| improve this answer | |
  • I decided to just use: get_the_permalink() - is that a problem? because it works fine from what it seems – JoaMika Jun 13 '18 at 15:57
  • Nope, that will work also. It's just that if there are any plugins that are hooking into the the_permalink_rss filter to apply parameters to the URL they won't work anymore. – ngearing Jun 13 '18 at 22:38

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.