示例#1
0
	<?php 
while (have_posts()) {
    the_post();
    ?>

	<item>
		<title><?php 
    the_title_rss();
    ?>
</title>
		<link><?php 
    the_permalink_rss();
    ?>
</link>
		<comments><?php 
    comments_link_feed();
    ?>
</comments>
		<pubDate><?php 
    echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false);
    ?>
</pubDate>
		<dc:creator><?php 
    the_author();
    ?>
</dc:creator>
		<?php 
    the_category_rss('rss2');
    ?>

	?>
>
	<title type="text"><?php
		if ( is_singular() )
			printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() );
		elseif ( is_search() )
			printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
		else
			printf( ent2ncr( __( 'Comments for %s' ) ), get_bloginfo_rss( 'name' ) . get_wp_title_rss() );
	?></title>
	<subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>

	<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated>

<?php if ( is_singular() ) { ?>
	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php comments_link_feed(); ?>" />
	<link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?>" />
	<id><?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?></id>
<?php } elseif(is_search()) { ?>
	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" />
	<link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>" />
	<id><?php echo get_search_comments_feed_link('', 'atom'); ?></id>
<?php } else { ?>
	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('url'); ?>" />
	<link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('comments_atom_url'); ?>" />
	<id><?php bloginfo_rss('comments_atom_url'); ?></id>
<?php } ?>
<?php
	/**
	 * Fires at the end of the Atom comment feed header.
	 *
示例#3
0
/**
 * Return XML for full feed.
 * 
 * @param   array $feed_items Array of objects. Required attributes: ID (=post id), blog_id
 * @return  string
 */
function get_feed_xml($feed_items)
{
    global $post;
    $rss_language = Settings\get_site_option('language_slug');
    if (empty($rss_language) && defined('WPLANG')) {
        $rss_language = substr(WPLANG, 0, 2);
    }
    ob_start();
    echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
    ?>

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	<?php 
    do_action('rss2_ns');
    ?>
>

<channel>
	<title><?php 
    echo get_feed_title();
    ?>
</title>
	<atom:link href="<?php 
    echo get_feed_url();
    ?>
" rel="self" type="application/rss+xml" />
	<link><?php 
    echo get_feed_url();
    ?>
</link>
	<description><?php 
    echo get_feed_description();
    ?>
</description>
	<lastBuildDate><?php 
    echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), FALSE);
    ?>
</lastBuildDate>
	<language><?php 
    echo $rss_language;
    ?>
</language>
	<sy:updatePeriod><?php 
    echo apply_filters('rss_update_period', 'hourly');
    ?>
</sy:updatePeriod>
	<sy:updateFrequency><?php 
    echo apply_filters('rss_update_frequency', '1');
    ?>
</sy:updateFrequency>
	<?php 
    do_action('rss2_head');
    foreach ($feed_items as $feed_item) {
        switch_to_blog($feed_item->blog_id);
        $post = get_post($feed_item->ID);
        setup_postdata($post);
        ?>
		
		<item>
			<title><?php 
        the_title_rss();
        ?>
</title>
			<link><?php 
        the_permalink_rss();
        ?>
</link>
			<comments><?php 
        comments_link_feed();
        ?>
</comments>
			<pubDate><?php 
        echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', TRUE), FALSE);
        ?>
</pubDate>
			<dc:creator><?php 
        the_author();
        ?>
</dc:creator>
			<?php 
        the_category_rss('rss2');
        ?>
			
			<guid isPermaLink="false"><?php 
        the_guid();
        ?>
</guid>
	<?php 
        if (get_option('rss_use_excerpt')) {
            ?>
			<description><![CDATA[<?php 
            the_excerpt_rss();
            ?>
]]></description>
	<?php 
        } else {
            ?>
			<description><![CDATA[<?php 
            the_excerpt_rss();
            ?>
]]></description>
		<?php 
            $content = \Inpsyde\MultisiteFeed\get_the_content_feed('rss2');
            ?>
		<?php 
            if (strlen($content) > 0) {
                ?>
			<content:encoded><![CDATA[<?php 
                echo $content;
                ?>
]]></content:encoded>
		<?php 
            } else {
                ?>
			<content:encoded><![CDATA[<?php 
                the_excerpt_rss();
                ?>
]]></content:encoded>
		<?php 
            }
            ?>
	<?php 
        }
        ?>
			<wfw:commentRss><?php 
        echo esc_url(get_post_comments_feed_link(NULL, 'rss2'));
        ?>
</wfw:commentRss>
			<slash:comments><?php 
        echo get_comments_number();
        ?>
</slash:comments>
	<?php 
        rss_enclosure();
        do_action('rss2_item');
        ?>
		</item>
		
		<?php 
        restore_current_blog();
    }
    ?>
	
</channel>
</rss>
<?php 
    $xml = ob_get_contents();
    ob_end_clean();
    return $xml;
}
示例#4
0
		echo apply_filters( 'rss_update_frequency', $frequency );
	?></sy:updateFrequency>
	<?php
	/**
	 * Fires at the end of the RSS2 Feed Header.
	 *
	 * @since 2.0.0
	 */
	do_action( 'rss2_head');

	while( have_posts()) : the_post();
	?>
	<item>
		<title><?php the_title_rss() ?></title>
		<link><?php the_permalink_rss() ?></link>
		<comments><?php comments_link_feed(); ?></comments>
		<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
		<dc:creator><![CDATA[<?php the_author() ?>]]></dc:creator>
		<?php the_category_rss('rss2') ?>

		<guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php if (get_option('rss_use_excerpt')) : ?>
		<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
<?php else : ?>
		<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
	<?php $content = get_the_content_feed('rss2'); ?>
	<?php if ( strlen( $content ) > 0 ) : ?>
		<content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded>
	<?php else : ?>
		<content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
	<?php endif; ?>