<?xml version="1.0" encoding="UTF-8"?> <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/"
><channel><title>PSD to Wordpress &#187; show</title> <atom:link href="http://www.sramekdesign.com/tag/show/feed/" rel="self" type="application/rss+xml" /><link>http://www.sramekdesign.com</link> <description>Get your PSD sliced into the XHTML valid Wordpress theme. SramekDesign offers cheap and fast PSD to Wordpress conversion service.</description> <lastBuildDate>Tue, 30 Mar 2010 08:22:59 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Wordpress: display posts from certain category</title><link>http://www.sramekdesign.com/wordpress/wordpress-display-posts-from-certain-category/</link> <comments>http://www.sramekdesign.com/wordpress/wordpress-display-posts-from-certain-category/#comments</comments> <pubDate>Sun, 08 Mar 2009 09:46:06 +0000</pubDate> <dc:creator>Tomas Sramek</dc:creator> <category><![CDATA[Wordpress]]></category> <category><![CDATA[category]]></category> <category><![CDATA[loop]]></category> <category><![CDATA[query_posts]]></category> <category><![CDATA[show]]></category> <category><![CDATA[showposts]]></category> <category><![CDATA[WP_Query]]></category><guid
isPermaLink="false">http://www.sramekdesign.com/?p=185</guid> <description><![CDATA[
Recently my client&#8217;s design required displaying posts in sidebar only from one category. To solve this problem I decided to use class WP_Query.
The first we have to create instance of WP_Query:Then call method query(); to start the query. This is actually same as you would be using query_posts();
Parameter cat indicates which category&#8217;s posts are shown. [...]]]></description> <content:encoded><![CDATA[<div
class="tweetmeme_button" style="float: right; margin: 0 0 10px 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.sramekdesign.com%2Fwordpress%2Fwordpress-display-posts-from-certain-category%2F"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=?url=http%3A%2F%2Fwww.sramekdesign.com%2Fwordpress%2Fwordpress-display-posts-from-certain-category%2F&amp;source=TomSramek&amp;style=normal&amp;hashtags=category,loop,query_posts,show,showposts,Wordpress,WP_Query" height="61" width="51" /><br
/> </a></div><p>Recently my client&#8217;s design required displaying posts in sidebar only from one category. To solve this problem I decided to use class WP_Query.</p><p>The first we have to create instance of WP_Query:</p><pre lang="php"><?php $recent = new WP_Query(); ?></pre><p>Then call method query(); to start the query. This is actually same as you would be using query_posts();<br
/> Parameter <strong>cat</strong> indicates which category&#8217;s posts are shown. Parameter <strong>showposts</strong> is the number of posts to be displayed.</p><pre lang="php"><?php $recent->query('cat=1&#038;showposts=5'); ?></pre><p>Now we can use loop:</p><pre class="brush: php;">
&lt;?php while($recent-&gt;have_posts()) : $recent-&gt;the_post(); ?&gt;
&lt;!-- Here goes some code --&gt;
&lt;?php endwhile; ?&gt;
</pre><p>Final code that displays last 5 posts&#8217; permalinks from category with ID=1 looks like this:</p><pre class="brush: php;">
&lt;h2&gt;Last posts&lt;/h2&gt;
&lt;?php $recent = new WP_Query(); ?&gt;
&lt;?php $recent-&gt;query('cat=1&amp;showposts=5'); ?&gt;
&lt;?php while($recent-&gt;have_posts()) : $recent-&gt;the_post(); ?&gt;
&lt;ul&gt;
	&lt;li&gt;
            &lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;
            &lt;?php the_title(); ?&gt;
            &lt;/a&gt;
       &lt;/li&gt;
&lt;/ul&gt;
&lt;?php endwhile; ?&gt;
</pre><p>Using your own WP_Query instance and loop prevents you from problems that might cause plugins&#8217; loops and use of conditional tags.</p> ]]></content:encoded> <wfw:commentRss>http://www.sramekdesign.com/wordpress/wordpress-display-posts-from-certain-category/feed/</wfw:commentRss> <slash:comments>15</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 7/13 queries in 0.005 seconds using disk

Served from: www.sramekdesign.com @ 2010-08-01 07:32:59 -->