内容营销

使用特色图像和版权声明(内容前和内容后)自定义您的 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>&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 首席营销官是 开放洞察 和创始人 Martech Zone。 道格拉斯帮助了数十家成功的 MarTech 初创公司,协助进行了超过 5 亿美元的 MarTech 收购和投资尽职调查,并继续协助公司实施和自动化其销售和营销策略。 道格拉斯是国际公认的数字化转型和 MarTech 专家和演讲者。 道格拉斯还是一本傻瓜指南和一本商业领导力书籍的出版作者。

相关文章

返回顶部按钮
关闭

检测到Adblock

Martech Zone 我们能够免费为您提供这些内容,因为我们通过广告收入、联属链接和赞助从我们的网站中获利。 如果您在浏览我们的网站时删除广告拦截器,我们将不胜感激。