样式RSS提要?

时间:2012-07-24 13:24:50

标签: wordpress wordpress-plugin wordpress-theming

我正在尝试设置用户可以看到的RSS Feed。所以他们所看到的只是帖子中的图像,WYSIWYG编辑器中的文本以及作为主题一部分的按钮。

以下是single.php模板文件中的按钮:

<div class="bottomgift clearfix">
<a target="_blank" rel="nofollow" href="<?php getCustomField('Affiliate Link'); ?>" class="go-button">Go</a>
</div>

如何添加所有这些以设置RSS Feed的样式?

在Functions.php中

function modRSS($content) {
   global $post;

   if ( has_post_thumbnail( $post->ID ) ){
      $content = '<div>' . get_the_post_thumbnail( $post->ID, 'full', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
   }

   $content = $content . '<a href="' . getCustomField('Affiliate Link') . '">Go</a>';

   return $content;
}

add_filter('the_excerpt_rss', 'modRSS');
add_filter('the_content_feed', 'modRSS');

1 个答案:

答案 0 :(得分:1)

您可以非常轻松地在WordPress RSS提要中添加或修改任何语法。

这里有一些代码可以从这里开始...... http://webdesignzo.com/show-featured-images-in-rss-feed-feedburner/为了您的目的进行了一些修改。

function modRSS($content) {
   global $post;

   if ( has_post_thumbnail( $post->ID ) ){
      $content = '<div>' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
   }

   $content = $content . '<div class="bottomgift clearfix"><a target="_blank" rel="nofollow" href="' . getCustomField('Affiliate Link') . '" class="go-button">Go</a</div>';

   //Adding Custom Fields
   $content = $content . get_post_meta($post->ID,'custom_field_name', true);

   return $content;
}

add_filter('the_excerpt_rss', 'modRSS');
add_filter('the_content_feed', 'modRSS');

我的代码是未经测试,但是这样的内容应该是你想要的。

P.S。正如您的问题标题所暗示的那样,这不是每个说的样式,而是更多地添加标记。

相关问题