简体   繁体   English

如何在wordpress中获取自定义帖子类型的RSS源?

[英]How to get RSS feeds for custom post type in wordpress?

I want separate feed of each custom post type so that I can utilise it in mobile apps. 我想要每个自定义帖子类型的单独提要,以便我可以在移动应用程序中使用它。 Most of the resources on the web describe the same thing to do as: 网络上的大多数资源都描述了同样的事情:

www.your-website.com/feed/?post_type=custom_post_type_name

I tried this but it generates same feed for all post types that includes all posts and page. 我尝试了这个,但它为包含所有帖子和页面的所有帖子类型生成相同的Feed。 Am I doing something wrong? 难道我做错了什么? Is there any other way to do this? 有没有其他方法可以做到这一点?

This article has helped me achieve this on several websites in the past. 这篇文章帮助我在过去的几个网站上实现了这一点。

http://www.wpbeginner.com/wp-tutorials/how-to-make-a-separate-rss-feed-for-each-custom-post-type-in-wordpress/ http://www.wpbeginner.com/wp-tutorials/how-to-make-a-separate-rss-feed-for-each-custom-post-type-in​​-wordpress/

Also it may not always be necessary but adding this to functions.php adds RSS links to the header of your website. 此外,它可能并不总是必要的,但将其添加到functions.php会将RSS链接添加到您网站的标题中。

// Add RSS feed links to head.
add_theme_support('automatic-feed-links');

有一个免费的插件。

https://wordpress.org/plugins/custom-post-type-rss-feed/

You should try to add to your functions.php the following filter: 您应该尝试添加到您的functions.php以下过滤器:

function my_custom_feed($qv) {
  if (isset($qv['feed']))
      $qv['post_type'] = get_query_var('post_type');
  return $qv;
}
add_filter('request', 'my_custom_feed');

this way you are changing the post showing into feeds, from your standard post to custom post type defined in query parameters 这样您就可以将帖子显示为Feed,从标准帖子更改为查询参数中定义的自定义帖子类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM