wc_products_rss_feed

Products RSS Feed.

Description

wc_products_rss_feed(); 

Usage

  1. if ( !function_exists( 'wc_products_rss_feed' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-template-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wc_products_rss_feed(); 
  7.  

Defined (1)

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

/includes/wc-template-functions.php  
  1. function wc_products_rss_feed() { 
  2. // Product RSS 
  3. if ( is_post_type_archive( 'product' ) || is_singular( 'product' ) ) { 
  4.  
  5. $feed = get_post_type_archive_feed_link( 'product' ); 
  6.  
  7. echo '<link rel="alternate" type="application/rss+xml" title="' . esc_attr__( 'New products', woocommerce ) . '" href="' . esc_url( $feed ) . '" />'; 
  8.  
  9. } elseif ( is_tax( 'product_cat' ) ) { 
  10.  
  11. $term = get_term_by( 'slug', esc_attr( get_query_var( 'product_cat' ) ), 'product_cat' ); 
  12.  
  13. if ( $term ) { 
  14. $feed = add_query_arg( 'product_cat', $term->slug, get_post_type_archive_feed_link( 'product' ) ); 
  15. echo '<link rel="alternate" type="application/rss+xml" title="' . sprintf( esc_attr__( 'New products added to %s', woocommerce ), $term->name ) . '" href="' . esc_url( $feed ) . '" />'; 
  16. } elseif ( is_tax( 'product_tag' ) ) { 
  17.  
  18. $term = get_term_by( 'slug', esc_attr( get_query_var( 'product_tag' ) ), 'product_tag' ); 
  19.  
  20. if ( $term ) { 
  21. $feed = add_query_arg( 'product_tag', $term->slug, get_post_type_archive_feed_link( 'product' ) ); 
  22. echo '<link rel="alternate" type="application/rss+xml" title="' . sprintf( esc_attr__( 'New products tagged %s', woocommerce ), urlencode( $term->name ) ) . '" href="' . esc_url( $feed ) . '" />';