Tuesday, November 21, 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 fascinating factor about WordPress is that the featured picture has by no means been included into the RSS feed. It is a bit unlucky, as choosing 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:

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 need 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 limitless chase and aggravating. There are many instances that I can monitor 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 embody 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 may 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