独自のテーマを用いたWordpressにてサイト運営をしています。
現在、functions.phpに以下の設定を書き込んでRSSを出力しています。
//RSS出力設定
add_theme_support( 'automatic-feed-links' );
//RSSカスタム投稿設定
function add_custom_post_feed($query) {
if (is_feed()) {
$post_type = $query->get('post_type');
if (empty($post_type)) {
$query->set('post_type', array(
'public'=>true
));
}
return $query;
}
}
add_filter('pre_get_posts', 'add_custom_post_feed');
//RSS画像表示
function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) . '</p>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');
この状態からRSS2.0を出力するやり方を模索中です。
php、Wordpressともそれほど詳しくないので設定方法が検討もつきません。
おわかりになれる方、どうぞ分かりやすくお教えいただきますようお願いいたします。
あなたの回答
tips
プレビュー