<?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"

			>

	<channel>

		<title>Exclude Category from Recent Posts in Visual Composer &#8211; Themeco Community</title>
		<atom:link href="https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/feed/" rel="self" type="application/rss+xml" />
		<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/feed/</link>
		<description></description>
		<lastBuildDate>Mon, 13 Oct 2025 10:27:05 +0000</lastBuildDate>
		<generator>https://bbpress.org/?v=2.6.14</generator>
		<language>en-US</language>

		
														
					
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107267</guid>
					<title><![CDATA[Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107267</link>
					<pubDate>Thu, 18 Sep 2014 15:43:26 +0000</pubDate>
					<dc:creator>bwelds</dc:creator>

					<description>
						<![CDATA[
						<p>I am working on a home page layout (Integrity) with the X version of Visual Composer and would like to separate one category to give those posts their own section on the home page. Having a recent posts section with just that category is easy enough, but in my main recent posts listing I would love to exclude those posts so they are not displayed twice. </p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107349</guid>
					<title><![CDATA[Reply To: Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107349</link>
					<pubDate>Thu, 18 Sep 2014 17:49:05 +0000</pubDate>
					<dc:creator>Zeshan</dc:creator>

					<description>
						<![CDATA[
						<p>Hi there,</p>
<p>Thank you for writing in!</p>
<p>This isn&#8217;t a feature offered by X. However it could be possible with custom development. Because this requires a template change, I&#8217;d advise that you setup a <a href="http://theme.co/x/member/kb/how-to-setup-child-themes/" title="Child Themes" target="_blank" rel="nofollow">child theme</a>. This allows you to make code changes that won&#8217;t be overwritten when an <strong>X</strong> update is released. After your child theme is setup, please review how we recommend making template changes in <a href="http://theme.co/x/member/kb/customization-best-practices/" rel="nofollow">Customization Best Practices</a>.</p>
<p>After that, add the following code in your child theme&#8217;s <strong>functions.php</strong> file:</p>
<pre><code>// Recent Posts - Adding &quot;exclude_category&quot; to recent_posts shortcode
// ================================================================================

function x_shortcode_recent_posts2( $atts ) {
	extract( shortcode_atts( array(
	  &#039;id&#039;                =&gt; &#039;&#039;,
	  &#039;class&#039;             =&gt; &#039;&#039;,
	  &#039;style&#039;             =&gt; &#039;&#039;,
	  &#039;type&#039;              =&gt; &#039;&#039;,
	  &#039;count&#039;             =&gt; &#039;&#039;,
	  &#039;category&#039;          =&gt; &#039;&#039;,
	  &#039;exclude_category&#039;  =&gt; &#039;&#039;,
	  &#039;offset&#039;            =&gt; &#039;&#039;,
	  &#039;orientation&#039;       =&gt; &#039;&#039;,
	  &#039;no_image&#039;          =&gt; &#039;&#039;,
	  &#039;fade&#039;              =&gt; &#039;&#039;
	), $atts ) );

	$id                  = ( $id          != &#039;&#039;          ) ? &#039;id=&quot;&#039; . esc_attr( $id ) . &#039;&quot;&#039; : &#039;&#039;;
	$class               = ( $class       != &#039;&#039;          ) ? &#039;x-recent-posts cf &#039; . esc_attr( $class ) : &#039;x-recent-posts cf&#039;;
	$style               = ( $style       != &#039;&#039;          ) ? &#039;style=&quot;&#039; . $style . &#039;&quot;&#039; : &#039;&#039;;
	$type                = ( $type        == &#039;portfolio&#039; ) ? &#039;x-portfolio&#039; : &#039;post&#039;;
	$count               = ( $count       != &#039;&#039;          ) ? $count : 3;
	$category            = ( $category    != &#039;&#039;          ) ? $category : &#039;&#039;;
	$exclude_category    = ( $exclude_category    != &#039;&#039;  ) ? $exclude_category : &#039;&#039;;
	$category_type       = ( $type        == &#039;post&#039;      ) ? &#039;category_name&#039; : &#039;portfolio-category&#039;;
	$offset              = ( $offset      != &#039;&#039;          ) ? $offset : 0;
	$orientation         = ( $orientation != &#039;&#039;          ) ? &#039; &#039; . $orientation : &#039; horizontal&#039;;
	$no_image            = ( $no_image    == &#039;true&#039;      ) ? $no_image : &#039;&#039;;
	$fade                = ( $fade        == &#039;true&#039;      ) ? $fade : &#039;false&#039;;

	$output = &quot;&lt;div {$id} class=\&quot;{$class}{$orientation}\&quot; {$style} data-fade=\&quot;{$fade}\&quot;&gt;&quot;;

	  $q = new WP_Query( array(
	    &#039;orderby&#039;          =&gt; &#039;date&#039;,
	    &#039;post_type&#039;        =&gt; &quot;{$type}&quot;,
	    &#039;posts_per_page&#039;   =&gt; &quot;{$count}&quot;,
	    &#039;offset&#039;           =&gt; &quot;{$offset}&quot;,
	    &#039;cat&#039;              =&gt; &quot;{$exclude_category}&quot;,
	    &quot;{$category_type}&quot; =&gt; &quot;{$category}&quot;
	  ) );

	  if ( $q-&gt;have_posts() ) : while ( $q-&gt;have_posts() ) : $q-&gt;the_post();

	    if ( $no_image == &#039;true&#039; ) {
	      $image_output       = &#039;&#039;;
	      $image_output_class = &#039;no-image&#039;;
	    } else {
	      $image_output       = &#039;&lt;div class=&quot;x-recent-posts-img&quot;&gt;&#039; . get_the_post_thumbnail( get_the_ID(), &#039;entry-&#039; . x_get_option( &#039;x_stack&#039;, &#039;integrity&#039; ) . &#039;-cropped&#039;, NULL ) . &#039;&lt;/div&gt;&#039;;
	      $image_output_class = &#039;with-image&#039;;
	    }

	    $output .= &#039;&lt;a class=&quot;x-recent-post&#039; . $count . &#039; &#039; . $image_output_class . &#039;&quot; href=&quot;&#039; . get_permalink( get_the_ID() ) . &#039;&quot; title=&quot;&#039; . esc_attr( sprintf( __( &#039;Permalink to: &quot;%s&quot;&#039;, &#039;__x__&#039; ), the_title_attribute( &#039;echo=0&#039; ) ) ) . &#039;&quot;&gt;&#039;
	               . &#039;&lt;article id=&quot;post-&#039; . get_the_ID() . &#039;&quot; class=&quot;&#039; . implode( &#039; &#039;, get_post_class() ) . &#039;&quot;&gt;&#039;
	                 . &#039;&lt;div class=&quot;entry-wrap&quot;&gt;&#039;
	                   . $image_output
	                   . &#039;&lt;div class=&quot;x-recent-posts-content&quot;&gt;&#039;
	                     . &#039;&lt;h3 class=&quot;h-recent-posts&quot;&gt;&#039; . get_the_title() . &#039;&lt;/h3&gt;&#039;
	                     . &#039;&lt;span class=&quot;x-recent-posts-date&quot;&gt;&#039; . get_the_date() . &#039;&lt;/span&gt;&#039;
	                   . &#039;&lt;/div&gt;&#039;
	                 . &#039;&lt;/div&gt;&#039;
	               . &#039;&lt;/article&gt;&#039;
	             . &#039;&lt;/a&gt;&#039;;

	  endwhile; endif; wp_reset_postdata();
	
	$output .= &#039;&lt;/div&gt;&#039;;

	return $output;
}

add_filter(&#039;init&#039;, function() {
	remove_shortcode( &#039;recent_posts&#039; );

	add_shortcode( &#039;recent_posts&#039;, &#039;x_shortcode_recent_posts2&#039; );
});
</code></pre>
<p>After that you need to add a new attribute to your recent posts shortcode, i.e. <strong>exclude_category=&#8221;&#8221;</strong>. You can exclude multiple categories by adding the ID of the category with a minus &#8220;-&#8221; sign before it, and separate multiple categories with commas. Example:</p>
<pre><code>// Single Category
[recent_posts type=&quot;post&quot; count=&quot;4&quot; orientation=&quot;horizontal&quot; exclude_category=&quot;-21&quot;]

// Multiple Categories
[recent_posts type=&quot;post&quot; count=&quot;4&quot; orientation=&quot;horizontal&quot; exclude_category=&quot;-21, -20, -13, -15&quot;]
</code></pre>
<p>To find out the &#8220;ID&#8221; of a category, just go to it&#8217;s edit page (see: <a href="http://prntscr.com/4o135o" rel="nofollow">http://prntscr.com/4o135o</a>) and in the URL find <strong>tag_id</strong> variable (see: <a href="http://prntscr.com/4o13ty" rel="nofollow">http://prntscr.com/4o13ty</a>)</p>
<p>Hope this helps. 🙂</p>
<p>Thank you.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107715</guid>
					<title><![CDATA[Reply To: Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107715</link>
					<pubDate>Fri, 19 Sep 2014 02:41:21 +0000</pubDate>
					<dc:creator>bwelds</dc:creator>

					<description>
						<![CDATA[
						<p>When I add that block of code to my child theme&#8217;s function.php file, everything breaks. All I see is a white screen both front-end and admin. Removing the code and all returns to well.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107735</guid>
					<title><![CDATA[Reply To: Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107735</link>
					<pubDate>Fri, 19 Sep 2014 03:34:55 +0000</pubDate>
					<dc:creator>Rad</dc:creator>

					<description>
						<![CDATA[
						<p>Hi there,</p>
<p>I just checked the code for parse error. And it doesn&#8217;t have any error. It could be that you replaced the entire code of your functions.php including the opening <code>&lt;?php</code> from the first line. You should only append the given code at the end of your child theme&#8217;s functions.php</p>
<p>Thanks!</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107769</guid>
					<title><![CDATA[Reply To: Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107769</link>
					<pubDate>Fri, 19 Sep 2014 05:22:47 +0000</pubDate>
					<dc:creator>bwelds</dc:creator>

					<description>
						<![CDATA[
						<p>That&#8217;s what I did. But I guess I&#8217;ll try it again. Fingers crossed.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107781</guid>
					<title><![CDATA[Reply To: Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-107781</link>
					<pubDate>Fri, 19 Sep 2014 05:55:17 +0000</pubDate>
					<dc:creator>Kosher K</dc:creator>

					<description>
						<![CDATA[
						<p>Hi There,</p>
<p>If still doesn&#8217;t work, you can provide us the login access of your site so we can check on your set-up</p>
<p>Thanks</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-108900</guid>
					<title><![CDATA[Reply To: Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-108900</link>
					<pubDate>Sat, 20 Sep 2014 23:58:46 +0000</pubDate>
					<dc:creator>bwelds</dc:creator>

					<description>
						<![CDATA[
						<p>I am getting a parse error in the code you provided. It is the only thing added to the functions.php provided with the child theme from your site. So the opening tag is fine. Once I save it, the error I get says:</p>
<p>Parse error: syntax error, unexpected T_FUNCTION in /public_html/home/wp-content/themes/x-child-integrity-light/functions.php on line 81</p>
<p>Line 81 is:</p>
<p><code>add_filter(&#039;init&#039;, function() {</code></p>
<p>I have not changed anything else in the code. </p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-108902</guid>
					<title><![CDATA[Reply To: Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-108902</link>
					<pubDate>Sun, 21 Sep 2014 00:09:05 +0000</pubDate>
					<dc:creator>bwelds</dc:creator>

					<description>
						<![CDATA[
						<p>Not sure why it wasn&#8217;t parsing function in the add_filter line. I moved the add and remove shortcode lines into their own function, and then put that function name in the add_filter and the error is gone.</p>
<pre><code>
function change_shortcode()
{
	remove_shortcode( &#039;recent_posts&#039; );
	add_shortcode( &#039;recent_posts&#039;, &#039;x_shortcode_recent_posts2&#039; );

}

add_filter(&#039;init&#039;, &#039;change_shortcode&#039;);</code></pre>
<p>Going to continue testing.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-108971</guid>
					<title><![CDATA[Reply To: Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-108971</link>
					<pubDate>Sun, 21 Sep 2014 03:30:17 +0000</pubDate>
					<dc:creator>Christian</dc:creator>

					<description>
						<![CDATA[
						<p>Thanks. Let us know how it goes.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-109193</guid>
					<title><![CDATA[Reply To: Exclude Category from Recent Posts in Visual Composer]]></title>
					<link>https://theme.co/archive/forums/topic/exclude-category-from-recent-posts-in-visual-composer/#post-109193</link>
					<pubDate>Sun, 21 Sep 2014 16:56:48 +0000</pubDate>
					<dc:creator>bwelds</dc:creator>

					<description>
						<![CDATA[
						<p>Got it working. Thanks for the help.</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

