Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#13058 closed defect (bug) (fixed)

Feed link not working with non-category taxonomy in wp_list_categories()

Reported by: greenshady's profile greenshady Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Feeds Keywords: dev-feedback has-patch needs-testing
Focuses: Cc:


Since wp_list_categories() now allows you to specify a taxonomy, its arguments should work with any taxonomy.

Currently, if you enter a value for feed or feed_type, a correct feed URL isn't shown.

To reproduce, try this:

	<?php wp_list_categories( array( 'taxonomy' => 'post_tag', 'feed' => 'RSS' ) ); ?>

Attachments (5)

13058.diff (3.2 KB) - added by blepoxp 14 years ago.
Fixes rss link for custom taxonomies
13058-2.diff (2.9 KB) - added by blepoxp 14 years ago.
13058-3.diff (3.0 KB) - added by blepoxp 14 years ago.
More standards cleanup plus used add_query_arg per sivel's suggestion.
13058-4.diff (3.0 KB) - added by blepoxp 14 years ago.
Changed function name
13058.2.diff (2.9 KB) - added by ryan 14 years ago.
13058-4.diff minus add_query_arg

Download all attachments as: .zip

Change History (18)

#1 @scribu
14 years ago

  • Component changed from General to Feeds

14 years ago

Fixes rss link for custom taxonomies

#2 @blepoxp
14 years ago

  • Keywords has-patch needs-testing added

This patch creates a new function in link-template.php called get_taxonomy_feed_link. It also makes get_category_feed_link call get_taxonomy_feed_link. It also updates the code that use to call get_category_feed_link to use get_taxonomy_feed_link.

I also had to add the extra arg in xmlrpc.php that instance was using the 3rd argument

#3 @dd32
14 years ago

  • Keywords needs-patch added; has-patch needs-testing removed

Patch review:

  • xmlrpc.php change is not needed, get_category_link() doesnt have a 3rd arg.
  • Should check if the taxonomy has rewrite enabled, ie. get the taxonomy permastruct, not the general permastruct, Its possible to register a taxonomy which does not use the inbuilt rules, those taxonomies will need to filter this function if they have a special structure.
  • @package isnt needed for function-level documentation, leave that for the file-level documentation
  • Coding standards:
     if ( Something )
        // do something
        // do something else
    • Spaces around language structs (if)
    • Spaces around conditionals
    • Skip the {'s if its only a single line
    • Spaces around concatenation ( something".$var."= vs something" . $var . "=

Patch looks good otherwise, most of those are things i'd change upon commit, but thought i'd give a review since the rewrite code will need updating.

14 years ago

#4 @blepoxp
14 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

13058-2.diff cleans up the coding standards, removes the diff on xmlrpc.php and compensates for custom query_vars in custom taxonomies.

The patch actually worked ok for determining whether to use custom rewrite rules or not. Consensus in wordpress-dev was that custom rewrite rules for custom taxonomies should not be used if default permalinks are selected in admin GUI. This was actually working.

What wasn't working was the scenario where default permalinks are selected in the admin GUI and a custom query_var had been registered for the custom taxonomy. I have modified the code to compensate for this.

I looked over and modified my code accordingly. Please let me know if I misread any of the standards.

14 years ago

More standards cleanup plus used add_query_arg per sivel's suggestion.

#5 @ryan
14 years ago

It should be get_term_feed_link() to compliment get_term_link(). Does add_query_arg() encode the ampersands?

14 years ago

Changed function name

#6 @blepoxp
14 years ago

Attached ticket has updated function name. add_query_arg does not appear to encode ampersands.

#7 @nacin
14 years ago

I'm pretty sure add query arg actually un-encodes any ampersands before adding said query arg.

#8 @blepoxp
14 years ago

If anyone wants to test this for me with various permalink structures or whatever, here's some code:

Put this in your theme's functions.php

function testers(){
	register_taxonomy( 'people', 'post', array( 'hierarchical' => false, 'label' => 'People', 'query_var' => true, 'rewrite' => true ) );


Put this in sidebar.php

	<?php wp_list_categories( array( 'taxonomy' => 'people' , 'feed' => 'rss')); ?>

Then go to create / edit posts and add at least one with a person taxonomy. At that point, links should show up in your sidebar and the RSS link should link to the feed of posts in that term/taxonomy. (I also tested changing the query_var arg)

#9 @blepoxp
14 years ago

  • Keywords dev-feedback added

My patch still works but i found an issue I need some feedback on. It has to do with rewriting the permalinks. I think its simalar to #13022 but I'm not certain the comments apply to this ticket. In short, I need to know if the following errors have to be fixed for this ticket to be complete, if it it's plugin territory and not an issue, or if it deserves a separate ticket.

Here's the problem:
1) Follow the steps in the above post so you can reproduce. 2) Set your permalink structure to default. 2) Go to homepage / refresh 3) Follow link to RSS feed 4) View feed as exspected 5) Return to home page.

6) Return to permalinks... i did this in a different browser tab. 7) change permalinks to anything but default 7) return to home page and click rss link 8) get error 9) go back to permalinks and change to a different (non default) structure 10) return to feed page with errors and refresh to find expected feed.

I've done more testing on this than needed to make sure i knew what was happening. You always receive the errors after first permalink update (step 7) and it always works after second permalink update (step 9).

The reason I bring this up is because you can perform the exact same sequence with category feeds and not get any errors.


14 years ago

13058-4.diff minus add_query_arg

#10 @ryan
14 years ago

Altered the patch to not use add_query_arg() since it doesn't escape. I haven't look at the #comment:9 issue yet.

#11 @ryan
14 years ago

(In [14711]) Introduce get_term_feed_link(). Use it in wp_list_categories(). Props blepoxp. see #13058

#12 @nacin
14 years ago


#13 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

I've been meaning to investigate the issue raised by blepoxp, but I think it is independent of this ticket. Closing.

Note: See TracTickets for help on using tickets.