custom post types - register_post_type - rewritefeeds, what's it for?

admin2025-01-07  5

The codex page for register_post_type seems to suggest that it should be possible to disable feed generation for custom post types:

 rewrite
    (boolean or array) (optional) Triggers the handling of rewrites for this post type. 
    To prevent rewrites, set to false.
...

$args array
...
    'feeds' => bool Should a feed permalink structure be built for this post type. 
        Defaults to has_archive value. 

I read that as meaning this:

 register_post_type('People', array('rewrite' => array('feeds' => false)));

would result in my 'People' archive page not having this:

<link rel="alternate" type="application/rss+xml" title="My Site &raquo; People Feed"
    href="/" />

in its head. However, the above is output in the HTML. Have I misunderstood, or done something wrong? I do not want a feed to be generated.

Any help much appreciated.

Toby

The codex page for register_post_type seems to suggest that it should be possible to disable feed generation for custom post types:

 rewrite
    (boolean or array) (optional) Triggers the handling of rewrites for this post type. 
    To prevent rewrites, set to false.
...

$args array
...
    'feeds' => bool Should a feed permalink structure be built for this post type. 
        Defaults to has_archive value. 

I read that as meaning this:

 register_post_type('People', array('rewrite' => array('feeds' => false)));

would result in my 'People' archive page not having this:

<link rel="alternate" type="application/rss+xml" title="My Site &raquo; People Feed"
    href="http://mysite.com/people/feed/" />

in its head. However, the above is output in the HTML. Have I misunderstood, or done something wrong? I do not want a feed to be generated.

Any help much appreciated.

Toby

Share Improve this question asked Aug 29, 2014 at 16:12 toby1kenobitoby1kenobi 2112 silver badges10 bronze badges 2
  • Maybe the feed link is hardcoded in the header template of your current theme. – anroesti Commented Aug 29, 2014 at 19:52
  • It's not unfortunately, it's coming out of wp_head() – toby1kenobi Commented Sep 1, 2014 at 8:12
Add a comment  | 

1 Answer 1

Reset to default 0

In case it helps anyone...

I had misunderstood - the feeds argument of 'rewrite' was merely about the formatting of feed URLs (to use rewriting).

What I want is not to have a feed URL output in the <head> of my custom post type pages. The only way I have found to do this, is using

remove_action( 'wp_head', 'feed_links_extra', 3 ); 

although this will suppress the feed in other circumstances (categories etc), not just for my custom post type. If anyone knows how to do what I want I'd love to hear from you!

Toby

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736262684a832.html

最新回复(0)