1

ユーザーに表示されるRSSフィードのスタイルを設定しようとしています。つまり、投稿の画像、WYSIWYGエディターのテキスト、テーマの一部であるボタンだけが表示されます。

これが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

WordPressRSSフィードの構文を非常に簡単に追加または修正できます。

ここからそれを行うためのいくつかのコードがあります... 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 に答える