内容营销
使用特色图像和版权声明(内容前和内容后)自定义您的 WordPress Feed
关于一件有趣的事 WordPress 就是 特色图片 从未被纳入 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');
您可以在我的提要上查看结果……在每篇文章的末尾都会显示特色图像以及版权和原始源链接。