Add Custom Content & Read More Link To WordPress RSS Feed

In your functions.php file add in the following code


// Customize the content of the custom RSS feed
function custom_rss_item($content) {
    global $post;

    // Build the custom content for each post item
    // Get the first 500 characters of the post content
	$custom_content .= '<p>' . esc_html(get_the_excerpt()) . '</p>';
	$custom_content .= '<p> </p>';
    $custom_content .= '<p>' . esc_html(substr(strip_tags(get_the_content()), 0, 500)) . '...</p>';
	$custom_content .= '<p> </p>';
	$custom_content .= '<p><a href="' . esc_url(get_permalink()) . '" target="_blank">Read The Full Article Herek</a></p>';

    // Combine with existing content
	$content = $custom_content;

    return $content;
}
add_filter('the_excerpt_rss', 'custom_rss_item');
add_filter('the_content_feed', 'custom_rss_item');
Disclaimer: The code on this website is provided "as is" and comes with no warranty. The author of this website does not accept any responsibility for issues arising from the use of code on this website. Before making any significant changes, ensure you take a backup of all files and do not work directly on a live/production website without thoughly testing your changes first.

Leave a Reply

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