WordPress支持RSS Feed输出,但在整站Feed源只会输出文章(post),如果你添加了自定义文章类型,需要将它们添加到WordPress的整站Feed源中。实现方法很简单,将下面的代码添加到主题的functions.php文件即可:
// 添加自定义文章类型到<a href="https://www.wpdaxue.com/tag/rss" title="查看与【RSS】相关的文章" target="_blank" rel="noopener">RSS</a> 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' ); |
// 添加自定义文章类型到<a href="https://www.wpdaxue.com/tag/rss" title="查看与【RSS】相关的文章" target="_blank" rel="noopener">RSS</a> 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)中的文章类型别名。
来源:
https://www.wpdaxue.com/add-custom-post-types-to-rss-feed.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32780.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57