<?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>Dev4Press&#187; query variable Tag Archives, page 1 of 1 | Dev4Press</title>
	<atom:link href="http://www.dev4press.com/tag/query-variable/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dev4press.com</link>
	<description>Premium Plugins and Themes for WordPress</description>
	<lastBuildDate>Tue, 21 May 2013 19:59:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>GD Custom Posts And Taxonomies Tools 3.5.9 Pro</title>
		<link>http://www.dev4press.com/2012/blog/plugins-news/gd-custom-posts-and-taxonomies-tools-3-5-9-pro/</link>
		<comments>http://www.dev4press.com/2012/blog/plugins-news/gd-custom-posts-and-taxonomies-tools-3-5-9-pro/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 15:15:03 +0000</pubDate>
		<dc:creator>MillaN</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[archive slug settings]]></category>
		<category><![CDATA[code library]]></category>
		<category><![CDATA[major bugs]]></category>
		<category><![CDATA[problems]]></category>
		<category><![CDATA[query variable]]></category>
		<category><![CDATA[rewrite rules]]></category>
		<category><![CDATA[slug]]></category>
		<category><![CDATA[wordpress link]]></category>

		<guid isPermaLink="false">http://www.dev4press.com/?p=14508</guid>
		<description><![CDATA[New minor revision is bringing many bugs fixed (related to rewrite rules, minor meta boxes issues and problem with interfering with WordPress links popup in the editor). Shared code library gdr2 is updated. New major plugin 3.6 version will soon go into full development.]]></description>
				<content:encoded><![CDATA[<p>New minor revision is bringing many bugs fixed (related to rewrite rules, minor meta boxes issues and problem with interfering with WordPress links popup in the editor). Shared code library gdr2 is updated. New major plugin 3.6 version will soon go into full development.</p>
<p>There were 2 major bugs in the code used to generate custom rewrite rules that were setting wrong query variables in some instances (categories used in rewrite rules were affected). Also, saving archive slug settings was broken. In the post editor, WordPress link popup wasn&#8217;t opening search for posts block due to interference by the code in the plugin. This is now fixed.</p>
<p>If you notice any more problems, please leave comment or report them in the forums.</p>
<blockquote><p><strong>GD Custom Posts And Taxonomies Tools Pro Overview:</strong><br />
<a href="http://www.dev4press.com/gd-custom-posts-and-taxonomies-tools/" target="_blank">http://www.dev4press.com/gd-custom-posts-and-taxonomies-tools/</a><br />
<strong>GD Custom Posts And Taxonomies Tools Pro Home Page:</strong><br />
<a href="http://www.dev4press.com/plugins/gd-taxonomies-tools/" target="_blank">http://www.dev4press.com/plugins/gd-taxonomies-tools/</a></p></blockquote>
<script src="http://feeds.feedburner.com/~s/adsense@gdragon.info?i=http://www.dev4press.com/2012/blog/plugins-news/gd-custom-posts-and-taxonomies-tools-3-5-9-pro/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://www.dev4press.com/2012/blog/plugins-news/gd-custom-posts-and-taxonomies-tools-3-5-9-pro/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Exclude subcategories from RSS feed</title>
		<link>http://www.dev4press.com/2011/tutorials/wordpress/tips/exclude-subcategories-from-rss-feed/</link>
		<comments>http://www.dev4press.com/2011/tutorials/wordpress/tips/exclude-subcategories-from-rss-feed/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 19:15:08 +0000</pubDate>
		<dc:creator>MillaN</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[children categories]]></category>
		<category><![CDATA[extra parameters]]></category>
		<category><![CDATA[main categories]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[query methods]]></category>
		<category><![CDATA[query posts]]></category>
		<category><![CDATA[query variable]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[sub categories]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.dev4press.com/?p=9672</guid>
		<description><![CDATA[WordPress WP_Query class is used to get posts for, basically, everything. And this class is very, very complicated. It has a long list of supported query variables, filters and actions to control the process. But, even with all that, there are some limitations in conventional methods of use.]]></description>
				<content:encoded><![CDATA[<p>WordPress WP_Query class is used to get posts for, basically, everything. And this class is very, very complicated. It has a long list of supported query variables, filters and actions to control the process. But, even with all that, there are some limitations in conventional methods of use.</p>
<p>If you want to exclude posts that belong to more than one category, you can use query variable called <strong>category__not_in</strong>. You need to specify array with category ID&#8217;s to exclude. But, if you want to exclude sub categories of the categories you have listed, this will no do. To exclude sub categories also, there is a little piece of code you can use. This is very useful for RSS feeds, since you can have better control over posts available in the feed.</p>
<p>First, here is normal example where we want to exclude posts from 4 different categories. First piece of code is classic example to get posts:</p>
<pre class="brush: php; title: ; notranslate">$args = array(&quot;category__not_in&quot; =&gt; array(2, 7, 43, 66));
$posts = get_posts($args);</pre>
<p>And the other one is to do this with RSS feed:</p>
<pre class="brush: php; title: ; notranslate">add_filter(&quot;pre_get_posts&quot;, array(&amp;$this, &quot;d4p_rss_query&quot;));
function d4p_rss_query($query) {
  if ($query-&gt;is_feed) {
    $cats = array(2, 7, 43, 66);
    $query-&gt;set(&quot;category__not_in&quot;, $cats);
  }
  return $query;
}</pre>
<p>But, if these 4 categories have subcategories, than you have a problem, posts in the sub categories will still be in the results. Here is the simple code to change that.</p>
<pre class="brush: php; title: ; notranslate">$cats = array(2, 7, 43, 66);
$main_cats = array(2, 7, 43, 66);
foreach ($main_cats as $cat) {
  $cats = array_merge($cats, get_term_children($cat, &quot;category&quot;));
}
$args = array(&quot;category__not_in&quot; =&gt; $cats);
$posts = get_posts($args);</pre>
<p>First and second line both contain same list of categories. This is to make sure that main categories are also included, and that we can go through the list to get children categories in lines 3 to 5. Again, here is the code for RSS feed.</p>
<pre class="brush: php; title: ; notranslate">add_filter(&quot;pre_get_posts&quot;, array(&amp;$this, &quot;d4p_rss_query&quot;));
function d4p_rss_query($query) {
  if ($query-&gt;is_feed) {
    $cats = array(2, 7, 43, 66);
    $main_cats = array(2, 7, 43, 66);
    foreach ($main_cats as $cat) {
      $cats = array_merge($cats, get_term_children($cat, &quot;category&quot;));
    }
    $query-&gt;set(&quot;category__not_in&quot;, $cats);
  }
  return $query;
}</pre>
<p>You can modify <strong>$args</strong> further with extra parameters, or you can use it with query_posts() function or other query methods. This same methods is used here on Dev4Press to control RSS feeds.</p>
<script src="http://feeds.feedburner.com/~s/adsense@gdragon.info?i=http://www.dev4press.com/2011/tutorials/wordpress/tips/exclude-subcategories-from-rss-feed/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://www.dev4press.com/2011/tutorials/wordpress/tips/exclude-subcategories-from-rss-feed/feed/</wfw:commentRss>
		<slash:comments>1</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: enhanced
Content Delivery Network via cdn.dev4press.com

 Served from: www.dev4press.com @ 2013-05-22 10:20:15 by W3 Total Cache -->