我是一个完全的Wordpress noob。我需要卷曲一个wordpress网站(来自php)并以rss格式获取两件事:
1.所有类别(例如somewpsite.com/categories/?rss)
2.对于一个类别,所有帖子。它们需要包含标题和全身(不是描述)(例如somewpsite.com/someposttitle/rss/?fullbody=1)
我知道,上面的链接是错误的,我试图解释我需要实现的目标。那么:我如何正确编写上面的2个URL?
谢谢!
PS:如果有帮助,我也可以访问Wordpress网站的源代码。
答案 0 :(得分:1)
第二个网址将跟随网址
http://thedailyq.org/feed/?cat=3
http://blog.atomixsystem.com/category/categoryname/feed/
和
第一个
在wp-includes中包含文件夹feed-rss2.php文件
<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'); ?>
>
之后您将添加此代码,然后您将在rss中获得类别列表
<?php $args = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => '',
'show_count' => 0,
'hide_empty' => 0,
'use_desc_for_title' => 0,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 0,
'title_li' => '',
'show_option_none' => '',
'number' => null,
'echo' => 1,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'category',
'walker' => null
); ?>
<?php
$allcats = get_categories('hide_empty=0&style=none&parent=0');
echo "<br/>";
echo '<category_name>';
foreach ($allcats as $cat) :
$customInCatQuery = new WP_Query($args);
if ($customInCatQuery->have_posts()) :
echo $cat->name."~";
?>
<?php
endif;
?>
<?php
wp_reset_query();
endforeach;
echo '</category_name>';
?>
我希望你能用这段代码解决。 谢谢