get_the_category_rss [ WordPress Function ]
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Retrieve all of the post categories, formatted for use in feeds.
All of the categories for the current post in the feed loop, will be retrieved and have feed markup added, so that they can easily be added to the RSS2, Atom, or RSS1 and RSS0.91 RDF feeds.
Source
<?php
function get_the_category_rss($type = null) {
if ( empty($type) )
$type = get_default_feed();
$categories = get_the_category();
$tags = get_the_tags();
$the_list = '';
$cat_names = array();
$filter = 'rss';
if ( 'atom' == $type )
$filter = 'raw';
if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
$cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
}
if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
$cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
}
$cat_names = array_unique($cat_names);
foreach ( $cat_names as $cat_name ) {
if ( 'rdf' == $type )
$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
elseif ( 'atom' == $type )
$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), esc_attr( $cat_name ) );
else
$the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n";
}
return apply_filters('the_category_rss', $the_list, $type);
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/get the category rss « WordPress Codex
Description. Retrieve all of the post categories, formatted for use in feeds. All of the categories for the current post in the feed loop, will be retrieved and have ...
codex.wordpress.org - Docs for page feed.php
get_the_category_rss (line 300). Retrieve ... string get_the_category_rss ([string $type = null]) ... see: get_the_category_rss() For better explanation. since: 0.71 ...
phpdoc.wordpress.org - get_the_category_rss | A HitchHackers guide through WordPress
Feb 12, 2011 ... function get_the_category_rss($type = null) {}. Retrieve all of the post categories, formatted for use in feeds. All of the categories for the current ...
hitchhackerguide.com - 常用函数-get_the_category_rss() | WordPress啦!
常用函数-get_the_category_rss(). 说明. 检索所有文章类别,并格式化以便在feed中 使用。 feed循环中当前文章的所有类别都将被检索,并添加feed markup,这样 ...
www.wordpress.la