<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Using WP_Query() to make custom queries within WordPress templates</title>
	<atom:link href="http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/feed/" rel="self" type="application/rss+xml" />
	<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/</link>
	<description>Coding Tutorials, hints &#38; tips in PHP, jQuery, CSS &#38; HTML</description>
	<lastBuildDate>Thu, 11 Mar 2010 13:40:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Aery</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-11156</link>
		<dc:creator>Aery</dc:creator>
		<pubDate>Tue, 27 Oct 2009 17:36:49 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-11156</guid>
		<description>Thanks for the quick response.

Let me try this new way.</description>
		<content:encoded><![CDATA[<p>Thanks for the quick response.</p>
<p>Let me try this new way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Robinson</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-11151</link>
		<dc:creator>Paul Robinson</dc:creator>
		<pubDate>Tue, 27 Oct 2009 13:36:45 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-11151</guid>
		<description>Normally with featured page items you don&#039;t want them to change when you change pages, but it is easy (once you know how) to allow it to change pages.

Just do this with your custom query:
[php]
//put this above your custom query
$paged = (get_query_var(&#039;paged&#039;)) ? get_query_var(&#039;paged&#039;) : 1;
//now for the custom query example
$wp_query = new WP_Query(&#039;cat=5&amp;posts_per_page=5&amp;paged=&#039;.$paged);
[/php]
Hopefully that will help. ;)

&lt;strong&gt;P.S&lt;/strong&gt; Sorry about the code highlighting not working. I&#039;m having a few problems with the plugin I use. I&#039;m trying to fix it now.</description>
		<content:encoded><![CDATA[<p>Normally with featured page items you don&#8217;t want them to change when you change pages, but it is easy (once you know how) to allow it to change pages.</p>
<p>Just do this with your custom query:</p>
<pre class="brush: php;">
//put this above your custom query
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
//now for the custom query example
$wp_query = new WP_Query('cat=5&#038;posts_per_page=5&#038;paged='.$paged);
</pre>
<p>Hopefully that will help. <img src='http://return-true.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>P.S</strong> Sorry about the code highlighting not working. I&#8217;m having a few problems with the plugin I use. I&#8217;m trying to fix it now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aery</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-11147</link>
		<dc:creator>Aery</dc:creator>
		<pubDate>Tue, 27 Oct 2009 10:24:43 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-11147</guid>
		<description>Hi Veneficus and Paul,

Thanks for the exellent trick with WP_Query. I hope you can help me with basic problem.

I intend to make a custome query which will showcast only featured posts in my homepage. However, on using custom query, pagination doent seem to work.

The custom query is - 

have_posts()) : $recent-&gt;the_post();?&gt;

*** Do some stuff ***






Now, the problem is even after clicking &quot;Older Entries&quot; or &quot;Newer Entries&quot;, the page URL changes to domain.com/page/2 but the contents remain same.

It looks like pagination isnt working with WP_Query. 

I would be really greateful if you can suggest something to make it work.</description>
		<content:encoded><![CDATA[<p>Hi Veneficus and Paul,</p>
<p>Thanks for the exellent trick with WP_Query. I hope you can help me with basic problem.</p>
<p>I intend to make a custome query which will showcast only featured posts in my homepage. However, on using custom query, pagination doent seem to work.</p>
<p>The custom query is &#8211; </p>
<p>have_posts()) : $recent-&gt;the_post();?&gt;</p>
<p>*** Do some stuff ***</p>
<p>Now, the problem is even after clicking &#8220;Older Entries&#8221; or &#8220;Newer Entries&#8221;, the page URL changes to domain.com/page/2 but the contents remain same.</p>
<p>It looks like pagination isnt working with WP_Query. </p>
<p>I would be really greateful if you can suggest something to make it work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Veneficus Unus</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-8667</link>
		<dc:creator>Veneficus Unus</dc:creator>
		<pubDate>Thu, 16 Jul 2009 08:56:59 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-8667</guid>
		<description>Hi Jim,

I&#039;m not sure. I thought it might have been a bug in WordPress, but I&#039;ve just tested it &amp; my recent posts widget works fine when searching.

As a rule of thumb I always run the search through WP main query system instead of making a separate one, meaning overwrite &lt;code&gt;$wp_query&lt;/code&gt; with the new query, as I find it stops all sorts of strange things happening. However, I don&#039;t know if that would solve your problem.

Sorry if I haven&#039;t been much help. It&#039;s a rather stange problem.</description>
		<content:encoded><![CDATA[<p>Hi Jim,</p>
<p>I&#8217;m not sure. I thought it might have been a bug in WordPress, but I&#8217;ve just tested it &amp; my recent posts widget works fine when searching.</p>
<p>As a rule of thumb I always run the search through WP main query system instead of making a separate one, meaning overwrite <code>$wp_query</code> with the new query, as I find it stops all sorts of strange things happening. However, I don&#8217;t know if that would solve your problem.</p>
<p>Sorry if I haven&#8217;t been much help. It&#8217;s a rather stange problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Isaacs</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-8662</link>
		<dc:creator>Jim Isaacs</dc:creator>
		<pubDate>Wed, 15 Jul 2009 22:55:49 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-8662</guid>
		<description>Does anyone know why the search template is negating any new WP_Query instances I would create.

This includes the one in the &quot;Recent Posts&quot; widget.

For example add &quot;Recent Posts&quot;  widget to a global sidebar. Show that sidebar on the search.php template. Then watch it disappear. Looks like some how WordPress accomodated for this some how, but in my sub queries I am not, the way they are.

Anyone have an idea about this.

To note: I have already tried the following...
$myQuery-&gt;query_vars[&#039;s&#039;] = &#039;&#039;;
$myQuery-&gt;is_search = false;

// Start the Sub Loop...</description>
		<content:encoded><![CDATA[<p>Does anyone know why the search template is negating any new WP_Query instances I would create.</p>
<p>This includes the one in the &#8220;Recent Posts&#8221; widget.</p>
<p>For example add &#8220;Recent Posts&#8221;  widget to a global sidebar. Show that sidebar on the search.php template. Then watch it disappear. Looks like some how WordPress accomodated for this some how, but in my sub queries I am not, the way they are.</p>
<p>Anyone have an idea about this.</p>
<p>To note: I have already tried the following&#8230;<br />
$myQuery-&gt;query_vars['s'] = &#8221;;<br />
$myQuery-&gt;is_search = false;</p>
<p>// Start the Sub Loop&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Veneficus Unus</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-8209</link>
		<dc:creator>Veneficus Unus</dc:creator>
		<pubDate>Sat, 13 Jun 2009 10:32:58 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-8209</guid>
		<description>I think I understand. However accessing the MySQL query that WordPress generates directly (if it&#039;s even possible) can be dangerous. You can do pretty much anything you like using the options given in &lt;code&gt;WP_Query()&lt;/code&gt; but for those times where it still isn&#039;t customiseable enough you will need to write a plugin that makes it&#039;s own connection to the database using WordPress&#039; database functions. Unfortuntately I haven&#039;t had any experience with that part of WordPress. So am unable to help you. :(</description>
		<content:encoded><![CDATA[<p>I think I understand. However accessing the MySQL query that WordPress generates directly (if it&#8217;s even possible) can be dangerous. You can do pretty much anything you like using the options given in <code>WP_Query()</code> but for those times where it still isn&#8217;t customiseable enough you will need to write a plugin that makes it&#8217;s own connection to the database using WordPress&#8217; database functions. Unfortuntately I haven&#8217;t had any experience with that part of WordPress. So am unable to help you. <img src='http://return-true.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deep</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-8205</link>
		<dc:creator>Deep</dc:creator>
		<pubDate>Sat, 13 Jun 2009 07:57:06 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-8205</guid>
		<description>It I think it helpfull for me, but I needed your help as I creating a plugin which returns a complete mysql query according to our custom requirments for getting posts, comments, pages ect. 
So 1st is that I&#039;m required to display posts according to that generated query at home page. 
and 2nd is, some time query has complex conditions then how I&#039;m able to manage these kind of complex customized queries for getting required results.</description>
		<content:encoded><![CDATA[<p>It I think it helpfull for me, but I needed your help as I creating a plugin which returns a complete mysql query according to our custom requirments for getting posts, comments, pages ect.<br />
So 1st is that I&#8217;m required to display posts according to that generated query at home page.<br />
and 2nd is, some time query has complex conditions then how I&#8217;m able to manage these kind of complex customized queries for getting required results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Veneficus Unus</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-7810</link>
		<dc:creator>Veneficus Unus</dc:creator>
		<pubDate>Wed, 13 May 2009 12:42:13 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-7810</guid>
		<description>No problem. Your probably right. Again thanks for telling me about it, I probably wouldn&#039;t have found it otherwise. :)</description>
		<content:encoded><![CDATA[<p>No problem. Your probably right. Again thanks for telling me about it, I probably wouldn&#8217;t have found it otherwise. <img src='http://return-true.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cosme</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-7796</link>
		<dc:creator>Cosme</dc:creator>
		<pubDate>Tue, 12 May 2009 21:15:54 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-7796</guid>
		<description>Yep... well... maybe they just obviated the issue, I&#039;m glad to help. By the way, thanks for sharing the knowledge, great blog. This particular tweak is hardly found.</description>
		<content:encoded><![CDATA[<p>Yep&#8230; well&#8230; maybe they just obviated the issue, I&#8217;m glad to help. By the way, thanks for sharing the knowledge, great blog. This particular tweak is hardly found.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Veneficus Unus</title>
		<link>http://return-true.com/2008/12/using-wp_query-to-make-custom-queries-within-wordpress-templates/comment-page-1/#comment-7756</link>
		<dc:creator>Veneficus Unus</dc:creator>
		<pubDate>Sun, 10 May 2009 11:16:18 +0000</pubDate>
		<guid isPermaLink="false">http://return-true.com/?p=282#comment-7756</guid>
		<description>Hey there Cosme. Your right, it shouldn&#039;t have that $ there, I&#039;ve no idea how I missed it, I&#039;ve no idea how the code has been working for the other commenters either, because you&#039;re right that $ will cause an error. :?

I&#039;ll correct the post now. Thanks for pointing it out. :)</description>
		<content:encoded><![CDATA[<p>Hey there Cosme. Your right, it shouldn&#8217;t have that $ there, I&#8217;ve no idea how I missed it, I&#8217;ve no idea how the code has been working for the other commenters either, because you&#8217;re right that $ will cause an error. <img src='http://return-true.com/wp-includes/images/smilies/icon_confused.gif' alt=':?' class='wp-smiley' /> </p>
<p>I&#8217;ll correct the post now. Thanks for pointing it out. <img src='http://return-true.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
