Aşağıdaki kodları wordpress kurulu olan root dizinine customFeed.php olarak kaydedin:
<?php define('WP_USE_THEMES', false); require('./wp-blog-header.php'); $num = $_GET["numberposts"] ?: '10'; $cat = $_GET["catid"]; $postID = $_GET["postid"]; $type = $_GET["type"]; switch ($type){ case "singlePost": $posts = get_posts('p='.$postID.'&numberposts=1'); break; case "catFeed": $posts = get_posts('category='.$cat.'&numberposts='.$num.'&order=ASC'); break; default: $posts = get_posts('numberposts='.$num.'&order=ASC'); } ?> <xml> <items> <?php if($type == "catFeed"){ ?> <catname><?php echo get_cat_name($cat); ?></catname> <catdescription><?php echo category_description($cat); ?></catdescription> <?php } ?> <?php foreach ($posts as $post) : start_wp(); ?> <item> <id><?php the_id();?></id> <title><![CDATA[<?php the_title();?>]]></title> <link><?php the_permalink_rss() ?></link> <author><?php the_author();?></author> <pubDate><?php the_date();?></pubDate> <teaser><![CDATA[<?php the_excerpt();?>]]></teaser> <?php if($type == "singlePost"){ ?> <content><![CDATA[<?php the_content();?>]]></content> <?php } ?> </item> <?php endforeach; ?> </items> </xml>
Kullanımı:
http://www.siteadi.com/customFeed.php?catid=1&type=catFeed&numberposts=20
http://www.siteadi.com/customFeed.php?postid=4&type=singlePost