1

我正在尝试设置用户将看到的 RSS 提要的样式。因此,他们所看到的只是帖子中的图像、所见即所得编辑器中的文本以及作为主题一部分的按钮。

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

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

如何添加所有这些来设置 RSS 提要的样式?

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

1 回答 1

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

我的代码未经测试,但这样的东西应该是你正在寻找的。

PS这不是你的问题标题所暗示的一个造型,而是更多地添加标记。

于 2012-07-24T14:12:11.647 回答