author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* RSS2 Feed Template for displaying RSS2 Posts feed. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
*/ |
|
7 |
||
9 | 8 |
header( 'Content-Type: ' . feed_content_type( 'rss2' ) . '; charset=' . get_option( 'blog_charset' ), true ); |
0 | 9 |
$more = 1; |
10 |
||
9 | 11 |
echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>'; |
0 | 12 |
|
5 | 13 |
/** |
14 |
* Fires between the xml and rss tags in a feed. |
|
15 |
* |
|
16 |
* @since 4.0.0 |
|
17 |
* |
|
18 |
* @param string $context Type of feed. Possible values include 'rss2', 'rss2-comments', |
|
19 |
* 'rdf', 'atom', and 'atom-comments'. |
|
20 |
*/ |
|
21 |
do_action( 'rss_tag_pre', 'rss2' ); |
|
22 |
?> |
|
0 | 23 |
<rss version="2.0" |
24 |
xmlns:content="http://purl.org/rss/1.0/modules/content/" |
|
25 |
xmlns:wfw="http://wellformedweb.org/CommentAPI/" |
|
26 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
|
27 |
xmlns:atom="http://www.w3.org/2005/Atom" |
|
28 |
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" |
|
29 |
xmlns:slash="http://purl.org/rss/1.0/modules/slash/" |
|
30 |
<?php |
|
31 |
/** |
|
32 |
* Fires at the end of the RSS root to add namespaces. |
|
33 |
* |
|
34 |
* @since 2.0.0 |
|
35 |
*/ |
|
36 |
do_action( 'rss2_ns' ); |
|
37 |
?> |
|
38 |
> |
|
39 |
||
40 |
<channel> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
<title><?php wp_title_rss(); ?></title> |
0 | 42 |
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> |
9 | 43 |
<link><?php bloginfo_rss( 'url' ); ?></link> |
44 |
<description><?php bloginfo_rss( 'description' ); ?></description> |
|
45 |
<lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate> |
|
0 | 46 |
<language><?php bloginfo_rss( 'language' ); ?></language> |
9 | 47 |
<sy:updatePeriod> |
48 |
<?php |
|
5 | 49 |
$duration = 'hourly'; |
50 |
||
51 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
* Filters how often to update the RSS feed. |
5 | 53 |
* |
54 |
* @since 2.1.0 |
|
55 |
* |
|
56 |
* @param string $duration The update period. Accepts 'hourly', 'daily', 'weekly', 'monthly', |
|
57 |
* 'yearly'. Default 'hourly'. |
|
58 |
*/ |
|
59 |
echo apply_filters( 'rss_update_period', $duration ); |
|
9 | 60 |
?> |
61 |
</sy:updatePeriod> |
|
62 |
<sy:updateFrequency> |
|
63 |
<?php |
|
5 | 64 |
$frequency = '1'; |
65 |
||
66 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
67 |
* Filters the RSS update frequency. |
5 | 68 |
* |
69 |
* @since 2.1.0 |
|
70 |
* |
|
71 |
* @param string $frequency An integer passed as a string representing the frequency |
|
72 |
* of RSS updates within the update period. Default '1'. |
|
73 |
*/ |
|
74 |
echo apply_filters( 'rss_update_frequency', $frequency ); |
|
9 | 75 |
?> |
76 |
</sy:updateFrequency> |
|
0 | 77 |
<?php |
78 |
/** |
|
79 |
* Fires at the end of the RSS2 Feed Header. |
|
80 |
* |
|
81 |
* @since 2.0.0 |
|
82 |
*/ |
|
9 | 83 |
do_action( 'rss2_head' ); |
0 | 84 |
|
9 | 85 |
while ( have_posts() ) : |
86 |
the_post(); |
|
87 |
?> |
|
0 | 88 |
<item> |
9 | 89 |
<title><?php the_title_rss(); ?></title> |
90 |
<link><?php the_permalink_rss(); ?></link> |
|
91 |
<?php if ( get_comments_number() || comments_open() ) : ?> |
|
16 | 92 |
<comments><?php comments_link_feed(); ?></comments> |
9 | 93 |
<?php endif; ?> |
0 | 94 |
|
16 | 95 |
<dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator> |
96 |
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> |
|
97 |
<?php the_category_rss( 'rss2' ); ?> |
|
0 | 98 |
<guid isPermaLink="false"><?php the_guid(); ?></guid> |
16 | 99 |
|
9 | 100 |
<?php if ( get_option( 'rss_use_excerpt' ) ) : ?> |
16 | 101 |
<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> |
9 | 102 |
<?php else : ?> |
16 | 103 |
<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> |
9 | 104 |
<?php $content = get_the_content_feed( 'rss2' ); ?> |
105 |
<?php if ( strlen( $content ) > 0 ) : ?> |
|
16 | 106 |
<content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded> |
107 |
<?php else : ?> |
|
108 |
<content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded> |
|
109 |
<?php endif; ?> |
|
9 | 110 |
<?php endif; ?> |
16 | 111 |
|
9 | 112 |
<?php if ( get_comments_number() || comments_open() ) : ?> |
16 | 113 |
<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link( null, 'rss2' ) ); ?></wfw:commentRss> |
114 |
<slash:comments><?php echo get_comments_number(); ?></slash:comments> |
|
9 | 115 |
<?php endif; ?> |
16 | 116 |
|
9 | 117 |
<?php rss_enclosure(); ?> |
16 | 118 |
|
9 | 119 |
<?php |
120 |
/** |
|
121 |
* Fires at the end of each RSS2 feed item. |
|
122 |
* |
|
123 |
* @since 2.0.0 |
|
124 |
*/ |
|
125 |
do_action( 'rss2_item' ); |
|
126 |
?> |
|
0 | 127 |
</item> |
128 |
<?php endwhile; ?> |
|
129 |
</channel> |
|
130 |
</rss> |