<?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 to set order by for [recent_posts] &#8211; Themeco Community</title>
		<atom:link href="https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/feed/" rel="self" type="application/rss+xml" />
		<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/feed/</link>
		<description></description>
		<lastBuildDate>Mon, 13 Oct 2025 20:25:51 +0000</lastBuildDate>
		<generator>https://bbpress.org/?v=2.6.14</generator>
		<language>en-US</language>

		
														
					
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-76834</guid>
					<title><![CDATA[How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-76834</link>
					<pubDate>Sat, 02 Aug 2014 19:45:45 +0000</pubDate>
					<dc:creator>MulderDSM</dc:creator>

					<description>
						<![CDATA[
						<p>I&#8217;m using this code to display a couple or rows of portfolio items I have.</p>
<p>[recent_posts type=&#8221;portfolio&#8221; category=&#8221;products&#8221; count=&#8221;4&#8243; orientation=&#8221;horizontal&#8221;]</p>
<p>[recent_posts type=&#8221;portfolio&#8221; category=&#8221;products&#8221; count=&#8221;4&#8243; offset=&#8221;4&#8243; orientation=&#8221;horizontal&#8221;]</p>
<p>All works well, except I&#8217;d like to see these in alphabetical order by title. What do I need to edit?</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-77224</guid>
					<title><![CDATA[Reply To: How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-77224</link>
					<pubDate>Mon, 04 Aug 2014 01:54:45 +0000</pubDate>
					<dc:creator>Christian</dc:creator>

					<description>
						<![CDATA[
						<p>Hey there,</p>
<p>You can edit <strong>shortcodes.php</strong> located in <strong>wp-content\plugins\x-shortcodes\functions</strong>. Search for the function <strong>x_shortcode_recent_posts</strong>. Under that function, look for the line</p>
<p><code>&#039;orderby&#039;          =&gt; &#039;date&#039;,</code></p>
<p>Change date to title. If you want to order it ascending, below it, add the line </p>
<p><code>&#039;order&#039;            =&gt; &#039;ASC&#039;,</code></p>
<p>The problem with this is that you need to do this every plugin update. With that said, you&#8217;ll want to have a modified copy of the shortcode in your functions.php. In order for us to do that, we need to rename the function and the shortcode tag of the modified copy because it would create a conflict if you create the same function. <strong>Add the code below in your functions.php.</strong>.</p>
<pre><code>function x_shortcode_recent_posts_custom( $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 ) );

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

  $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;title&#039;,
      &#039;order&#039;            =&gt; &#039;ASC&#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 ( $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_shortcode( &#039;recent_posts_custom&#039;, &#039;x_shortcode_recent_posts_custom&#039; );</code></pre>
<p>We call this new shortcode <strong>[recent_posts_obt]</strong> (order by title). You can use it like the Recent Post shortcode. You can also override the Recent Posts shortcode (see <a href="http://theme.co/x/member/forums/topic/add-excerpt-to-recent-posts-shortcode/#post-66964" rel="nofollow">http://theme.co/x/member/forums/topic/add-excerpt-to-recent-posts-shortcode/#post-66964</a>).</p>
<p>Hope that helps. 🙂</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-77830</guid>
					<title><![CDATA[Reply To: How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-77830</link>
					<pubDate>Tue, 05 Aug 2014 00:10:15 +0000</pubDate>
					<dc:creator>MulderDSM</dc:creator>

					<description>
						<![CDATA[
						<p>That did the trick! Thank&#8217;s so much! Long term, you may want to consider that has option when you update the plug in. I can see others needing to sort recent posts by more than just the date.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-78070</guid>
					<title><![CDATA[Reply To: How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-78070</link>
					<pubDate>Tue, 05 Aug 2014 12:16:14 +0000</pubDate>
					<dc:creator>Cousett</dc:creator>

					<description>
						<![CDATA[
						<p>Glad this helped! </p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107195</guid>
					<title><![CDATA[Reply To: How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107195</link>
					<pubDate>Thu, 18 Sep 2014 13:29:03 +0000</pubDate>
					<dc:creator>Michael V</dc:creator>

					<description>
						<![CDATA[
						<p>Hi there,</p>
<p>Is it possible to sort the recent posts by a number that we enter as a tag?</p>
<p>Something like:</p>
<p>      &#8216;orderby&#8217;          =&gt; &#8216;tags&#8217;,<br />
      &#8216;order&#8217;            =&gt; &#8216;ASC&#8217;,</p>
<p>Thanks for the help,</p>
<p>Michael</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107280</guid>
					<title><![CDATA[Reply To: How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107280</link>
					<pubDate>Thu, 18 Sep 2014 16:03:14 +0000</pubDate>
					<dc:creator>Mrinal</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Michael, </p>
<p>Luckily, you can add tag parameter to recent posts shortcode as like the following:<br />
<code>[recent_posts count=&quot;4&quot; tag=&quot;tag-slug&quot;]</code></p>
<p>So, if you&#8217;ve done the above code customization described by us then just add the tag parameter in recent posts shortcode.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107311</guid>
					<title><![CDATA[Reply To: How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107311</link>
					<pubDate>Thu, 18 Sep 2014 16:36:47 +0000</pubDate>
					<dc:creator>Michael V</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Support,</p>
<p>Great! I&#8217;ll definitely use that!</p>
<p>But it&#8217;s not what I try to achieve right now: I don&#8217;t want to show all portfolio-item with a specific tag but I would like to show all the portfolio-item of a category ordered by tag value (alphabetical).</p>
<p>You did it by title here:</p>
<p>    $q = new WP_Query( array(<br />
      &#8216;orderby&#8217;          =&gt; &#8216;title&#8217;,<br />
      &#8216;order&#8217;            =&gt; &#8216;ASC&#8217;,<br />
      &#8216;post_type&#8217;        =&gt; &#8220;{$type}&#8221;,<br />
      &#8216;posts_per_page&#8217;   =&gt; &#8220;{$count}&#8221;,<br />
      &#8216;offset&#8217;           =&gt; &#8220;{$offset}&#8221;,<br />
      &#8220;{$category_type}&#8221; =&gt; &#8220;{$category}&#8221;<br />
    ) );</p>
<p>I&#8217;m sure it can be achieve easily but I don&#8217;t know which slug to use (I know &#8220;title&#8221; and &#8220;date&#8221;, but is there one for the tag?)!</p>
<p>Thanks for help!<br />
X support is great 😉</p>
<p>Michael</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107338</guid>
					<title><![CDATA[Reply To: How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107338</link>
					<pubDate>Thu, 18 Sep 2014 17:24:52 +0000</pubDate>
					<dc:creator>Michael V</dc:creator>

					<description>
						<![CDATA[
						<p>Or maybe it&#8217;s easier to sort by post meta ? :</p>
<p>‘orderby’ =&gt; ‘post_meta’,</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107389</guid>
					<title><![CDATA[Reply To: How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-107389</link>
					<pubDate>Thu, 18 Sep 2014 19:07:35 +0000</pubDate>
					<dc:creator>Zeshan</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Micheal,</p>
<p>Thank you for writing in!</p>
<p>Regretfully it isn&#8217;t possible with WP_Query function, however it could be possible with MySQL query but that would fall beyond the scope of support we can offer. You may wish to consult a developer, or a service like WerkPress or Elto 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>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-347115</guid>
					<title><![CDATA[Reply To: How to set order by for [recent_posts]]]></title>
					<link>https://theme.co/archive/forums/topic/how-to-set-order-by-for-recent_posts/#post-347115</link>
					<pubDate>Sat, 01 Aug 2015 12:08:40 +0000</pubDate>
					<dc:creator>eugenetim</dc:creator>

					<description>
						<![CDATA[
						<p>Hi. I want to make such trick with latest version of X theme (Cornerstone). Can you update the example of custom shortcode function if I need just reverse order of posts (by date) when I&#8217;ll use [recent_posts_obt] shortcode. Thank you!<br />
P.S. Important! I am using Icon stack.</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

