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 Publish Content material)


One fascinating factor about WordPress is that the featured picture has by no means been integrated 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 troublesome. Right here’s the code that I added to my WordPress features.php in my Baby Theme file:

perform prerssfeedcontent($content material) {
	world $publish;
	$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 typically discover that there are websites which might be stealing my content material and publishing it as their very own on their website. It’s an limitless chase and aggravating. There are many occasions that I can observe them down; different occasions, I can report them to their advert networks and internet hosting suppliers. However typically, they’re largely nameless and exhausting to trace down… if in any respect.

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

perform prepostrssfeedcontent($content material) {
	world $publish;
	$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 possibly can view the end result on my feed… the featured picture is displayed in addition to the copyright and unique supply hyperlinks on the finish of every publish.

View Martech Zone Feed



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments