Content Marketing

Customize Your WordPress Feed With A Featured Image and Copyright Statement (Pre and Post Content)

One interesting thing about WordPress is that the featured image has never been incorporated into the RSS feed. This is a bit unfortunate, as selecting or designing the featured image can draw much attention to an article.

Prepend Content To The Posts In Your RSS Feed

To prepend the featured image to your content isn’t too difficult. Here’s the code that I added to my WordPress functions.php in my Child Theme file:

function prerssfeedcontent($content) {
	global $post;
	$current_year = date('Y');
	$post_title = get_the_title( $post->ID );
	$post_link = get_permalink( $post->ID );
	$post_image = get_the_post_thumbnail( $post->ID, 'medium' );

	// Add the featured image
	if ( has_post_thumbnail( $post->ID ) ) {
		$precontent = '<p class="thumb">';
		$precontent .= '<a href="' .$post_link. '" title="' .$post_title. '">';
		$precontent .= $post_image;
		$precontent .= '</a></p>';
	}

	$content = $precontent . $content;

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

Additionally, I also want to add content at the end of my feed posts.

Append Content To The Posts In Your RSS Feed

As I’m reviewing backlinks to Martech Zone, I often find that there are sites that are stealing my content and publishing it as their own on their site. It’s an endless chase and aggravating. There are plenty of times that I can track them down; other times, I can report them to their ad networks and hosting providers. But often, they’re largely anonymous and hard to track down… if at all.

As a result, my only choice is to customize my feed and include a copyright statement so unauthorized site visitors can see the source. To do this, I updated the above function to prepend and append the information I wanted.

function prepostrssfeedcontent($content) {
	global $post;
	$current_year = date('Y');
	$post_title = get_the_title( $post->ID );
	$post_link = get_permalink( $post->ID );
	$post_image = get_the_post_thumbnail( $post->ID, 'medium' );
	$company_title = "DK New Media, LLC";
	$company_link = "https://dknewmedia.com";

	// Add the featured image
	if ( has_post_thumbnail( $post->ID ) ) {
		$precontent = '<p class="thumb">';
		$precontent .= '<a href="' .$post_link. '" title="' .$post_title. '">';
		$precontent .= $post_image;
		$precontent .= '</a></p>';
	}

	// Add the copyright
	$postcontent = '<p>&copy;';
	$postcontent .= $current_year;
	$postcontent .= ' <a href="'.$company_link.'">'.$company_title.'</a>, All rights reserved.</p>';
	$postcontent .= '<p>Originally Published on Martech Zone: <a href="'.$post_link.'">'.$post_title.'</a></p>';

	$content = $precontent . $content . $postcontent;

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

You can view the result on my feed… the featured image is displayed as well as the copyright and original source links at the end of each post.

View Martech Zone Feed

Douglas Karr

Douglas Karr is the founder of the Martech Zone and a recognized expert on digital transformation. Douglas has helped start several successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to launch his own platforms and services. He's a co-founder of Highbridge, a digital transformation consulting firm. Douglas is also a published author of a Dummie's guide and a business leadership book.

Related Articles

One Comment

  1. It was really a headache to see the RSS-to-email campaigns without no images because the RSS feed did not have the necessary tag to pull images from. Anyway, changed the functions.php file and now MailChimp can pull the required components and now the emails look beautiful.

    However, still the images in RSS feed look really big and wish to resize them to a suitable size. Needs to search more and find a solution for this.

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close

Adblock Detected

Martech Zone is able to provide you this content at no cost because we monetize our site through ad revenue, affiliate links, and sponsorships. We would appreciate if you would remove your ad blocker as you view our site.