How can I improve the performance of this query_posts loop?
I created a WordPress page template to build a customised XML feed for certain WordPress posts on my site. Specifically, the page template renders XML and only includes certain custom post types and only if these posts contain specific meta data.
I'm using the data to feed WordPress content to an iOS application. It seems to work great; however, the response times from the server vary and often fail. My hosting company ( MediaTemple ) has suggested I could improve performance by making the database query more efficient.
Are there any standard optimisation tips for this kind of query?
?php
$numposts = -1;
$posts = query_posts( 'showposts=' . $numposts . 'post_type=listings' );
header("Content-Type: application/rss+xml; charset=UTF-8");
echo '?xml version="1.0"?';
?
rss version="2.0"
channel
titleMy custom feed/title
?php foreach ($posts as $post) { if ( get_post_meta($post-ID, 'mymeta', true) ) { ?
item
various item elements...
/item
?php } ?
/channel
/rss
Topic ios loop query-posts database Wordpress optimization
Category Web