[wp-trac] [WordPress Trac] #21648: Enable feed autodiscovery for custom post type archives

WordPress Trac wp-trac at lists.automattic.com
Wed Sep 26 12:02:33 UTC 2012


#21648: Enable feed autodiscovery for custom post type archives
--------------------------+-----------------------
 Reporter:  mdgl          |       Owner:  nacin
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  3.5
Component:  Post Types    |     Version:  3.4.1
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+-----------------------

Comment (by mdgl):

 Yeah, this code is designed to be run during wp_head so should not rely on
 there being anything meaningful in the $post global (a common failing,
 however). A possible fix is to replace the following line in the patch:


 {{{
    $href = get_post_type_archive_feed_link( get_post_type() );
 }}}


 with:


 {{{
    $post_type_obj = get_queried_object();
    $href = get_post_type_archive_feed_link( $post_type_obj->name );
 }}}

 This is slightly fragile, but a similar approach is taken elsewhere in the
 codebase and I don't really want to open up the can of worms which is the
 nature and type of the queried object in the context of complex queries
 :-)

 You could argue it would be nicer for the two "get post type archive
 [feed] link" functions to default to the current post type automatically,
 but that would require changes in link-template.php also.

 Replacing the two subsequent calls to isset() with !empty() is not
 strictly necessary but would add further bulletproofing.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21648#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list