I'm trying to configure a custom feed for Wordpress so it hooks in to my iPhone app. However, I've got so far but I'm becoming more stuck now. The code below gets the latest posts from WordPress and formats them the way I need. However, were I'm getting stuck at the moment is I'm trying to now:
- Excluding a category from the feed below (e.g. excluding category ID 5).
-
Include another category to be 'sticky' (i.e category id 4), so even if it isn't in the latest 20 posts, it will still show in the feed.
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> <root> <items> <language><?php bloginfo_rss( 'language' ); ?></language> <?php while( have_posts()) : the_post(); ?> <item> <title><?php the_title_rss(); ?></title> <category><?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?></category> <pubDate><?php echo mysql2date('d M Y', get_post_time('Y-m-d', true), true); ?></pubDate> <?php $allcontent = get_the_content_feed('rss2'); ?> <description> <![CDATA[ <?php echo $allcontent; ?> ]]> </description> <link><?php the_permalink_rss() ?></link> <image> <?php if (has_post_thumbnail() ): $attachmentimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' ); echo $attachmentimage[0]; ?> <?php endif; ?> </image> <?php rss_enclosure(); ?> <?php do_action('rss2_item'); ?> </item> <?php endwhile; ?> </items> </root>