<?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>How can I exclude the active post from the recent post shortcode list? &#8211; Themeco Community</title>
		<atom:link href="https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/feed/" rel="self" type="application/rss+xml" />
		<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/feed/</link>
		<description></description>
		<lastBuildDate>Mon, 20 Oct 2025 10:16:42 +0000</lastBuildDate>
		<generator>https://bbpress.org/?v=2.6.14</generator>
		<language>en-US</language>

		
														
					
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-249106</guid>
					<title><![CDATA[How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-249106</link>
					<pubDate>Tue, 14 Apr 2015 09:32:54 +0000</pubDate>
					<dc:creator>Zsolt D</dc:creator>

					<description>
						<![CDATA[
						<p>Hi,</p>
<p>I use the recent post shortcode (with category), but the recent post list includes the active post too, which is unneccessary and confusing. How can I exclude the active post from the list?<br />
Sample:</p>
<blockquote class="wp-embedded-content" data-secret="wCOQMvy2qT"><p><a href="https://gendiagnosztika.hu/az-infertilitas-es-az-ivf-sikertelensegenek-immunologiai-okairol/" rel="nofollow">A meddőség immunológiai okairól</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="&#8220;A meddőség immunológiai okairól&#8221; &#8212; Istenhegyi Géndiagnosztika" src="https://gendiagnosztika.hu/az-infertilitas-es-az-ivf-sikertelensegenek-immunologiai-okairol/embed/#?secret=O1LGZUtyRN#?secret=wCOQMvy2qT" data-secret="wCOQMvy2qT" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br />
X and X-shortcode are up-to date.<br />
Thx</p>
<p>Zsolt</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-249157</guid>
					<title><![CDATA[Reply To: How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-249157</link>
					<pubDate>Tue, 14 Apr 2015 10:39:50 +0000</pubDate>
					<dc:creator>Thai</dc:creator>

					<description>
						<![CDATA[
						<p>Hello There,</p>
<p>Thanks for posting in!</p>
<p>This is only possible if you override the recent_post shortcode by customizing your own. Please add this following code below into <strong>functions.php</strong> file locates in child theme folder:</p>
<pre><code>
function x_shortcode_recent_posts_v2( $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;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, &#039;recent_posts&#039; ) );

  $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;;
  $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;;

  $js_params = array(
    &#039;fade&#039; =&gt; ( $fade == &#039;true&#039; )
  );

  $data = x_generate_data_attributes( &#039;recent_posts&#039;, $js_params );

  $output = &quot;&lt;div {$id} class=\&quot;{$class}{$orientation}\&quot; {$style} {$data} data-fade=\&quot;{$fade}\&quot; &gt;&quot;;
    $args = 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;,
      &quot;{$category_type}&quot; =&gt; &quot;{$category}&quot;
    );
    if(is_single()){
      $args[&#039;post__not_in&#039;] = array(get_the_ID());
    }
    $q = new WP_Query( $args );

    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-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_action(&#039;init&#039;, &#039;x_recent_posts_v2&#039;);

function x_recent_posts_v2() {
  remove_shortcode( &#039;recent_posts&#039; );
  add_shortcode( &#039;recent_posts&#039;, &#039;x_shortcode_recent_posts_v2&#039; );
}
</code></pre>
<p>Hope it helps.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-249251</guid>
					<title><![CDATA[Reply To: How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-249251</link>
					<pubDate>Tue, 14 Apr 2015 12:55:55 +0000</pubDate>
					<dc:creator>Zsolt D</dc:creator>

					<description>
						<![CDATA[
						<p>Hi,</p>
<p>it works perfect, thank you for your quick response. Excellent support.<br />
You may apply this function in the X core&#8230;?</p>
<p>Have a nice day!</p>
<p>Zsolt</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-249282</guid>
					<title><![CDATA[Reply To: How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-249282</link>
					<pubDate>Tue, 14 Apr 2015 13:27:33 +0000</pubDate>
					<dc:creator>Paul R</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Zsolt,</p>
<p>Yes, I&#8217;ll forward this to our web development team for review.</p>
<p>Thanks.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-311447</guid>
					<title><![CDATA[Reply To: How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-311447</link>
					<pubDate>Wed, 24 Jun 2015 11:18:57 +0000</pubDate>
					<dc:creator>Zsolt D</dc:creator>

					<description>
						<![CDATA[
						<p>Hi!</p>
<p>I changed the recent post function with your help, see above.</p>
<p>I am afraid, that after upgrading 4.x the suggested code isn&#8217;t valid, can you revise it?</p>
<p>(After upgrading X to 4.x pages with shortcode [recent_posts] fail to load<br />
I should manually search pages with the shortcode [recent_posts] and change to [x_recent_posts], but loose the function excluding the active page.)</p>
<p>Thanks</p>
<p>Zsolt</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-311549</guid>
					<title><![CDATA[Reply To: How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-311549</link>
					<pubDate>Wed, 24 Jun 2015 13:38:32 +0000</pubDate>
					<dc:creator>Thai</dc:creator>

					<description>
						<![CDATA[
						<p>Hi There,</p>
<p>Please update the previous code a bit:</p>
<pre><code>function x_shortcode_recent_posts_v2( $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;post&#039;,
    &#039;count&#039;       =&gt; &#039;&#039;,
    &#039;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, &#039;x_recent_posts&#039; ) );

  $allowed_post_types = apply_filters( &#039;cs_recent_posts_post_types&#039;, array( &#039;post&#039; =&gt; &#039;post&#039; ) );
  $type = ( isset( $allowed_post_types[$type] ) ) ? $allowed_post_types[$type] : &#039;post&#039;;

  $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;;
  $count         = ( $count       != &#039;&#039;          ) ? $count : 3;
  $category      = ( $category    != &#039;&#039;          ) ? $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;;

  $js_params = array(
    &#039;fade&#039; =&gt; ( $fade == &#039;true&#039; )
  );

  $data = cs_generate_data_attributes( &#039;recent_posts&#039;, $js_params );

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

    $args = 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;,
      &quot;{$category_type}&quot; =&gt; &quot;{$category}&quot;
    );
    if(is_single()){
      $args[&#039;post__not_in&#039;] = array(get_the_ID());
    }
    $q = new WP_Query( $args );

    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              = wp_get_attachment_image_src( get_post_thumbnail_id(), &#039;entry-cropped&#039; );
        $bg_image           = ( $image[0] != &#039;&#039; ) ? &#039; style=&quot;background-image: url(&#039; . $image[0] . &#039;);&quot;&#039; : &#039;&#039;;
        $image_output       = &#039;&lt;div class=&quot;x-recent-posts-img&quot;&#039; . $bg_image . &#039;&gt;&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;, csl18n() ), 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_action(&#039;init&#039;, &#039;x_recent_posts_v2&#039;);

function x_recent_posts_v2() {
  remove_shortcode( &#039;x_recent_posts&#039; );
  add_shortcode( &#039;x_recent_posts&#039;, &#039;x_shortcode_recent_posts_v2&#039; );
}</code></pre>
<p>Please replace all the <code>[recent_posts]</code> with <code>[x_recent_posts]</code>.</p>
<p>Let us know how it goes!</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-312427</guid>
					<title><![CDATA[Reply To: How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-312427</link>
					<pubDate>Thu, 25 Jun 2015 08:29:30 +0000</pubDate>
					<dc:creator>Zsolt D</dc:creator>

					<description>
						<![CDATA[
						<p>Hi!</p>
<p>Thank you. I updated the code, and it works fine with post, but I have one further question. I use &#8220;post-tags-and-categories-for-pages&#8221; plugin to list not only the posts but also the pages with the same categorie in different lists. The active page is not filtered with this code from the recent posts list. Can you change the code to filter not only the posts but the pages too? Thank you very much for your help.<br />
See here:</p>
<blockquote class="wp-embedded-content" data-secret="8XDaGFBrjV"><p><a href="https://gendiagnosztika.hu/meddosegi-vizsgalatok/" rel="nofollow">Meddőségi vizsgálatok</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="&#8220;Meddőségi vizsgálatok&#8221; &#8212; Istenhegyi Géndiagnosztika" src="https://gendiagnosztika.hu/meddosegi-vizsgalatok/embed/#?secret=oh91lj5Lch#?secret=8XDaGFBrjV" data-secret="8XDaGFBrjV" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>With kind regards:<br />
Zsolt</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-312601</guid>
					<title><![CDATA[Reply To: How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-312601</link>
					<pubDate>Thu, 25 Jun 2015 12:30:12 +0000</pubDate>
					<dc:creator>Zeshan</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Zsolt,</p>
<p>Thanks for writing in!</p>
<p>Recent posts shortcode is specifically for &#8220;Posts&#8221; and &#8220;Portfolio&#8221; items, that might be the reason it&#8217;s not filtering the pages. As it sounds like you might be having an issue with a third party plugin or script. Regretfully, we cannot provide support for third party plugins or scripts as our support policy in the sidebar states due to the fact that there is simply no way to account for all of the potential variables at play when using another developer&#8217;s plugin or script. Because of this, any questions you have regarding setup, integration, or troubleshooting any piece of functionality that is not native to X will need to be directed to the original developer.</p>
<p>Thank you for your understanding.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-401571</guid>
					<title><![CDATA[Reply To: How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-401571</link>
					<pubDate>Thu, 24 Sep 2015 21:37:38 +0000</pubDate>
					<dc:creator>vendinimarketing</dc:creator>

					<description>
						<![CDATA[
						<p>Hi there!</p>
<p>I&#8217;ve used the above snippet (reply #311549) in my child theme and the shortcode is working beautifully. However, I was wondering if there was an alteration I could make so that the X theme &#8220;Recent Posts&#8221; widget also excludes the current post.</p>
<p>An example of what I mean can be seen here:</p>
<p><a href="http://vendini.co/blog/2015/08/please-welcome-our-new-vp-of-customer-success-tricia-baker/" rel="nofollow">http://vendini.co/blog/2015/08/please-welcome-our-new-vp-of-customer-success-tricia-baker/</a></p>
<p>The widget generated &#8220;Recent Posts&#8221; displays Tricia Baker&#8217;s post in the list.<br />
The shortcode I added as a text widget called &#8220;Recent Posts 2&#8221; does not.</p>
<p>Thanks!</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-407318</guid>
					<title><![CDATA[Reply To: How can I exclude the active post from the recent post shortcode list?]]></title>
					<link>https://theme.co/archive/forums/topic/how-can-i-exclude-the-active-post-from-the-recent-post-shortcode-list/#post-407318</link>
					<pubDate>Fri, 25 Sep 2015 02:53:24 +0000</pubDate>
					<dc:creator>Friech</dc:creator>

					<description>
						<![CDATA[
						<p>Hi There,</p>
<p>Thanks for writing in! Regretfully this isn&#8217;t a feature offered by X. Recent post can only filter category and offset but not the active post. It could be possible with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities.</p>
<p>Thanks for understanding. Take care!</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

