WordPress支援RSS Feed輸出,但在整站Feed源隻會輸出文章(post),如果你添加瞭自定義文章類型,需要將它們添加到WordPress的整站Feed源中。實現方法很簡單,將下面的代碼添加到主題的functions.php文件即可:
1 2 3 4 5 6 7 |
// 添加自定義文章類型到RSS Feed輸出 function custom_feed_request( $vars ) { if (isset($vars['feed']) && !isset($vars['post_type'])) $vars['post_type'] = array( 'post', 'product', 'book' ); return $vars; } add_filter( 'request', 'custom_feed_request' ); |
// 添加自定義文章類型到RSS Feed輸出
function custom_feed_request( $vars ) {
if (isset($vars[‘feed’]) && !isset($vars[‘post_type’]))
$vars[‘post_type’] = array( ‘post’, ‘product’, ‘book’ );
return $vars;
}
add_filter( ‘request’, ‘custom_feed_request’ );
請根據自己的實際修改第 4 行數組(array)中的文章類型別名。