new rss channel

This commit is contained in:
arlemp@selectel.ru
2022-02-21 13:53:43 +03:00
parent 9f2f3e0805
commit 3727594359
3 changed files with 81 additions and 0 deletions

34
views/rss/rssnews.php Normal file
View File

@@ -0,0 +1,34 @@
<?echo '<?xml version="1.0" encoding="UTF-8"?>';?>
<rss version="2.0">
<channel>
<language>ru</language>
<copyright><?=date('Y')?>, Ветеринария и жизнь</copyright>
<title>Новости с сайта www.vetandlife.ru</title>
<link>https://www.vetandlife.ru</link>
<lastBuildDate><?=_U2RFC822(date('Y-m-d h:i:s'))?></lastBuildDate>
<description>Новости с сайта www.vetandlife.ru</description>
<image>
<url>https://vetandlife.ru/wp-content/themes/vij/pub/vij.png</url>
<title>Ветеринария и жизнь</title>
<link>https://www.vetandlife.ru</link>
</image>
<?foreach($posts as $post):?>
<item>
<title><?=htmlspecialchars($post->post_title)?></title>
<guid><?=get_permalink($post->ID);?></guid>
<description><?=htmlspecialchars($post->post_excerpt);?></description>
<?$category=get_the_category($post->ID);?>
<category><?=$category?></category>
<?$author = get_the_author($post->ID);?>
<?if (isset($author) and $author !== ''):?>
<author><?=$author?></author>
<?endif?>
<?if (has_post_thumbnail($post->ID)):?>
<enclosure url="<?=get_the_post_thumbnail_url($post->ID)?>" type="image/jpeg"/>
<?endif?>
<pubDate><?=_U2RFC822($post->post_date)?></pubDate>
<description><![CDATA[<?=strip_tags($post->post_content)?>]]></description>
</item>
<?endforeach?>
</channel>
</rss>