Created
December 27, 2014 14:01
-
-
Save thefuxia/ddce68bb97448a88a096 to your computer and use it in GitHub Desktop.
Always add category feed links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Plugin Name: T5 Category Feed Links */ | |
add_action( 'wp_head', function() { | |
$cats = get_categories(); | |
$html = '<link rel="alternate" type="%1$s" title="Category %2$s" href="%3$s" />'; | |
$type = feed_content_type(); | |
foreach ( $cats as $cat ) { | |
if ( 1 > $cat->count ) | |
continue; | |
$title = esc_attr( $cat->name ); | |
$url = esc_url( get_category_feed_link( $cat->cat_ID ) ); | |
printf( $html, $type, $title, $url ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment