Advertisement
Guest User

Untitled

a guest
Jul 31st, 2014
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.68 KB | None | 0 0
  1. <?php
  2. /**
  3.  * RSS2 Feed Template for displaying RSS2 Posts feed.
  4.  *
  5.  * @package WordPress
  6.  */
  7.  
  8. header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
  9. $more = 1;
  10.  
  11. echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
  12.  
  13. <rss version="2.0"
  14.     xmlns:content="http://purl.org/rss/1.0/modules/content/"
  15.     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  16.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  17.     xmlns:atom="http://www.w3.org/2005/Atom"
  18.     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  19.     xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  20.     <?php
  21.     /**
  22.      * Fires at the end of the RSS root to add namespaces.
  23.      *
  24.      * @since 2.0.0
  25.      */
  26.     do_action( 'rss2_ns' );
  27.     ?>
  28. >
  29.  
  30. <channel>
  31.     <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
  32.     <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
  33.     <link><?php bloginfo_rss('url') ?></link>
  34.     <description><?php bloginfo_rss("description") ?></description>
  35.     <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
  36.     <language><?php bloginfo_rss( 'language' ); ?></language>
  37.     <?php
  38.     $duration = 'hourly';
  39.     /**
  40.      * Filter how often to update the RSS feed.
  41.      *
  42.      * @since 2.1.0
  43.      *
  44.      * @param string $duration The update period.
  45.      *                         Default 'hourly'. Accepts 'hourly', 'daily', 'weekly', 'monthly', 'yearly'.
  46.      */
  47.     ?>
  48.     <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', $duration ); ?></sy:updatePeriod>
  49.     <?php
  50.     $frequency = '1';
  51.     /**
  52.      * Filter the RSS update frequency.
  53.      *
  54.      * @since 2.1.0
  55.      *
  56.      * @param string $frequency An integer passed as a string representing the frequency
  57.      *                          of RSS updates within the update period. Default '1'.
  58.      */
  59.     ?>
  60.     <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', $frequency ); ?></sy:updateFrequency>
  61.     <?php
  62.     /**
  63.      * Fires at the end of the RSS2 Feed Header.
  64.      *
  65.      * @since 2.0.0
  66.      */
  67.     do_action( 'rss2_head');
  68.  
  69.     while( have_posts()) : the_post();
  70.     $yoastmeta = get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true);
  71.     $category = get_the_category();
  72.     $permalink = get_permalink() . "#disqus_thread";
  73.     $image = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail');
  74.     $img = get_headers($image[0], 1);
  75.     ?>
  76.    
  77.     <item>
  78.         <title><?php the_title_rss() ?></title>
  79.         <link><?php the_permalink_rss() ?></link>
  80.         <comments><?php echo $permalink; ?></comments>
  81.         <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
  82.         <dc:creator><![CDATA[<?php the_author() ?>]]></dc:creator>
  83.         <category><?php echo $category[0]->cat_name; ?></category>
  84.         <guid isPermaLink="false"><?php the_guid(); ?></guid>
  85. <?php if (get_option('rss_use_excerpt')) : ?>
  86.         <description><![CDATA[<?php echo $yoastmeta; ?>]]></description>
  87. <?php else : ?>
  88.         <description><![CDATA[<?php echo $yoastmeta; ?>]]></description>
  89.     <?php $content = get_the_content_feed('rss2'); ?>
  90.     <?php if ( strlen( $content ) > 0 ) : ?>
  91.         <content:encoded><![CDATA[<?php echo $yoastmeta; ?>]]></content:encoded>
  92.     <?php else : ?>
  93.         <content:encoded><![CDATA[<?php echo $yoastmeta; ?>]]></content:encoded>
  94.     <?php endif; ?>
  95. <?php endif; ?>
  96.         <slash:comments><?php echo get_comments_number(); ?></slash:comments>
  97.         <enclosure url="<?php echo $image[0]; ?>" length="<?php echo $img["Content-Length"]; ?>"></enclosure>
  98. <?php rss_enclosure(); ?>
  99.     <?php
  100.     /**
  101.      * Fires at the end of each RSS2 feed item.
  102.      *
  103.      * @since 2.0.0
  104.      */
  105.     do_action( 'rss2_item' );
  106.     ?>
  107.     </item>
  108.     <?php endwhile; ?>
  109. </channel>
  110. </rss>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement