Tips, Web, WordPress
attention-image
attention-image

 
 
 
 
 

 
 
 
 
 
WordPressのRSSフィードに、投稿以外にも、全ての固定ページ及びCustom Post Typeの投稿を配信するようにするには以下のタグをfunctions.phpに追加するとRSSフィードにCustom Post Typeを含む全ての投稿を含めることができます。 RSSフィードに全ての固定ページ及びCustom Post Typeを含む投稿を配信する function custom_post_rss_set($query) { if ( is_feed() ) { $post_type = $query->get('post_type'); if ( empty($post_type) ){ $query->set( 'post_type','any'); } return $query; } } add_filter( 'pre_get_posts', 'custom_post_rss_set' ); さらに続けてRSSにサムネイル画像を含...

WordPressのRSSフィードに、投稿以外にも、全ての固定ページ及びCustom Post Typeの投稿を配信するようにするには以下のタグをfunctions.phpに追加するとRSSフィードにCustom Post Typeを含む全ての投稿を含めることができます。

RSSフィードに全ての固定ページ及びCustom Post Typeを含む投稿を配信する

function custom_post_rss_set($query) {
if ( is_feed() ) {
$post_type = $query->get('post_type');
if ( empty($post_type) ){
$query->set( 'post_type','any');
}
return $query;
}
}
add_filter( 'pre_get_posts', 'custom_post_rss_set' );

さらに続けてRSSにサムネイル画像を含める

function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) .
'</p>' . get_the_content();
}
return $content;
}
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');

最新ニュース



出典:総合データベースサイト「coron」 執筆者 : .

管理人のアンテナlive!

コメントを投稿(承認制)