2016-06-14 08:12:00

Related Docs

Do You Need Help or Expertise?

Is editing Source Code not Your Thing? Are you in a tight Time Schedule and need to deliver a fully scalable and safe solution fast to your Clients?

Maybe you want to incorporate the Software found on TukuToi unbranded and royalty free in your Clients Projects after customizing it as per your Projects requirements?

Or eventually you need some training on any WordPress Plugin, Theme or their creation and maintenance?

ShortCodeGroup Posts by Date (year and month)

Group Posts in a View Loop by Year and Month

This ShortCode let’s you “group” posts in a View by their Publish Date, by year and then month.

To use it, add this to functions.php:

add_shortcode('heading', 'my_heading');
function my_heading($atts, $content = '') {
  static $year = null;
  static $month = null;
  $condition = $atts['condition'];
  $value = $atts['value'];
  switch ($condition) {
      case 'year':
      case 'month':
        if ($condition != $value) {
            $condition = $value;
            return $content;
        }
        break;
  }
  return '';
}

Then use this new ShortCode in the Views loop as the below example:

[heading condition="year" value="2016"]
<h4>2016</h4>
[/heading]
[heading condition="month" value="June"]
<h5>June</h5>
[/heading]