內容營銷

使用特色圖像和版權聲明(內容前和內容後)自定義您的 WordPress Feed

關於一件有趣的事 WordPress EST闕樂 特色圖片 從未被納入 RSS 餵養。 這有點不幸,因為選擇或設計特色圖像可能會引起文章的大量關注。

將內容添加到 RSS 源中的帖子前面

將特色圖像添加到您的內容中並不是太困難。 這是我添加到 WordPress 的代碼 functions.php 在我 子主題 文件:

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');

此外,我還想在我的摘要帖子末尾添加內容。

將內容附加到 RSS 源中的帖子

當我正在審查反向鏈接時 Martech Zone,我經常發現有些網站竊取我的內容並將其作為自己的內容髮佈在他們的網站上。 這是無休止的追逐和惱怒。 很多時候我都可以找到他們; 其他時候,我可以將它們報告給他們的廣告網絡和託管提供商。 但通常情況下,他們大多是匿名的,很難追踪……如果有的話。

因此,我唯一的選擇是自定義我的提要並包含版權聲明,以便未經授權的網站訪問者可以看到源代碼。 為此,我更新了上述函數以添加和附加我想要的信息。

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://martech.zone/partner/dknewmedia/";

	// 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');

您可以在我的提要上查看結果……在每篇文章的末尾都會顯示特色圖像以及版權和原始源鏈接。

瀏覽 Martech Zone 餵寵物用具

Douglas Karr

Douglas Karr 是 CMO 的 開放洞察 和創始人 Martech Zone。 道格拉斯幫助了數十家成功的 MarTech 新創公司,協助進行了超過 5 億美元的 MarTech 收購和投資盡職調查,並繼續協助公司實施和自動化其銷售和行銷策略。 道格拉斯是國際公認的數位轉型和 MarTech 專家和演講者。 道格拉斯也是一本傻瓜指南和一本商業領導書的出版作者。

相關文章

返回頂部按鈕
關閉

檢測到Adblock

Martech Zone 我們能夠免費為您提供這些內容,因為我們通過廣告收入、聯屬鏈接和讚助從我們的網站中獲利。 如果您在瀏覽我們的網站時刪除廣告攔截器,我們將不勝感激。