feed_links_extra

Display the links to the extra feeds such as category feeds.

Description

feed_links_extra( (array) $args = array() ); 

Parameters (1)

0. $args — Optional. (array) => array()
Arguments.

Usage

  1. if ( !function_exists( 'feed_links_extra' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4. // Optional arguments. 
  5. $args = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = feed_links_extra($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. function feed_links_extra( $args = array() ) { 
  2. $defaults = array( 
  3. /** translators: Separator between blog name and feed type in feed links */ 
  4. 'separator' => _x('»', 'feed link'),  
  5. /** translators: 1: blog name, 2: separator(raquo), 3: post title */ 
  6. 'singletitle' => __('%1$s %2$s %3$s Comments Feed'),  
  7. /** translators: 1: blog name, 2: separator(raquo), 3: category name */ 
  8. 'cattitle' => __('%1$s %2$s %3$s Category Feed'),  
  9. /** translators: 1: blog name, 2: separator(raquo), 3: tag name */ 
  10. 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'),  
  11. /** translators: 1: blog name, 2: separator(raquo), 3: term name, 4: taxonomy singular name */ 
  12. 'taxtitle' => __('%1$s %2$s %3$s %4$s Feed'),  
  13. /** translators: 1: blog name, 2: separator(raquo), 3: author name */ 
  14. 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),  
  15. /** translators: 1: blog name, 2: separator(raquo), 3: search phrase */ 
  16. 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'),  
  17. /** translators: 1: blog name, 2: separator(raquo), 3: post type name */ 
  18. 'posttypetitle' => __('%1$s %2$s %3$s Feed'),  
  19. ); 
  20.  
  21. $args = wp_parse_args( $args, $defaults ); 
  22.  
  23. if ( is_singular() ) { 
  24. $id = 0; 
  25. $post = get_post( $id ); 
  26.  
  27. if ( comments_open() || pings_open() || $post->comment_count > 0 ) { 
  28. $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) ); 
  29. $href = get_post_comments_feed_link( $post->ID ); 
  30. } elseif ( is_post_type_archive() ) { 
  31. $post_type = get_query_var( 'post_type' ); 
  32. if ( is_array( $post_type ) ) 
  33. $post_type = reset( $post_type ); 
  34.  
  35. $post_type_obj = get_post_type_object( $post_type ); 
  36. $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name ); 
  37. $href = get_post_type_archive_feed_link( $post_type_obj->name ); 
  38. } elseif ( is_category() ) { 
  39. $term = get_queried_object(); 
  40.  
  41. if ( $term ) { 
  42. $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); 
  43. $href = get_category_feed_link( $term->term_id ); 
  44. } elseif ( is_tag() ) { 
  45. $term = get_queried_object(); 
  46.  
  47. if ( $term ) { 
  48. $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); 
  49. $href = get_tag_feed_link( $term->term_id ); 
  50. } elseif ( is_tax() ) { 
  51. $term = get_queried_object(); 
  52. $tax = get_taxonomy( $term->taxonomy ); 
  53. $title = sprintf( $args['taxtitle'], get_bloginfo('name'), $args['separator'], $term->name, $tax->labels->singular_name ); 
  54. $href = get_term_feed_link( $term->term_id, $term->taxonomy ); 
  55. } elseif ( is_author() ) { 
  56. $author_id = intval( get_query_var('author') ); 
  57.  
  58. $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) ); 
  59. $href = get_author_feed_link( $author_id ); 
  60. } elseif ( is_search() ) { 
  61. $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) ); 
  62. $href = get_search_feed_link(); 
  63. } elseif ( is_post_type_archive() ) { 
  64. $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) ); 
  65. $post_type_obj = get_queried_object(); 
  66. if ( $post_type_obj ) 
  67. $href = get_post_type_archive_feed_link( $post_type_obj->name ); 
  68.  
  69. if ( isset($title) && isset($href) ) 
  70. echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";