Saturday, July 1, 2023
HomeMobile MarketingCustomise Your WordPress Feed With A Featured Picture and Copyright Assertion (Pre...

Customise Your WordPress Feed With A Featured Picture and Copyright Assertion (Pre and Submit Content material)


One attention-grabbing factor about WordPress is that the featured picture has by no means been included into the RSS feed. This can be a bit unlucky, as deciding on or designing the featured picture can draw a lot consideration to an article.

Prepend Content material To The Posts In Your RSS Feed

To prepend the featured picture to your content material isn’t too tough. Right here’s the code that I added to my WordPress capabilities.php in my Little one Theme file:

operate prerssfeedcontent($content material) {
	world $put up;
	$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 picture
	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 material = $precontent . $content material;

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

Moreover, I additionally wish to add content material on the finish of my feed posts.

Append Content material To The Posts In Your RSS Feed

As I’m reviewing backlinks to Martech Zone, I usually discover that there are websites which can be stealing my content material and publishing it as their very own on their website. It’s an infinite chase and aggravating. There are many instances that I can observe them down; different instances, I can report them to their advert networks and internet hosting suppliers. However usually, they’re largely nameless and onerous to trace down… if in any respect.

In consequence, my solely alternative is to customise my feed and embrace a copyright assertion so unauthorized website guests can see the supply. To do that, I up to date the above operate to prepend and append the knowledge I wished.

operate prepostrssfeedcontent($content material) {
	world $put up;
	$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 picture
	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>Initially Revealed on Martech Zone: <a href="'.$post_link.'">'.$post_title.'</a></p>';

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

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

You’ll be able to view the consequence on my feed… the featured picture is displayed in addition to the copyright and unique supply hyperlinks on the finish of every put up.

View Martech Zone Feed

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments