內容營銷
使用特色圖像和版權聲明(內容前和內容後)自定義您的 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>©';
$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');
您可以在我的提要上查看結果……在每篇文章的末尾都會顯示特色圖像以及版權和原始源鏈接。