events to check

format(‘Y-md’); }
$arr_dates_events = array();

ini_set(‘memory_limit’, ‘512M’);
$count=0;
$T=0;
$V=0;
$A=0;
$M=0;
$Y=0;
$S=0;
$R=0;

$args = array(
‘posts_per_page’ => 100,
‘category__not_in’ => array(4, 1630, 1659, 1081) ,
‘orderby’ => ‘date’,
‘order’ => ‘ASC’,
‘nopaging’ => 1,

);

$d = ‘Y-md’;

// The Query
$the_query = new WP_Query( $args );
$months = array(’01’ => “Jan”, ’02’ => “Feb”, ’03’ => “Mar”, ’04’ => “Apr”, ’05’ => “May”, ’06’ => “Jun”, ’07’ => “Jul”, ’08’ => “Aug”, ’09’ => “Sep”, ’10’ => “Oct”, 11 => “Nov”, ’12’ => “Dec”);
$post_allowed = [‘Recorded Speech or Media Event’, ‘Speeches by others’, ‘Yogi Event’, ‘Transcript’, ‘Audios’, ‘Videos’, ‘Video DP’ ];
$properOrderedArray = array(‘R’, ‘S’, ‘Y’, ‘T’, ‘A’, ‘V’ );
$length = 1;
$substr = function( $element ) use ( $length ) {
return substr( $element, 0, $length );
};

// The Loop
$array = array();
if ( $the_query->have_posts() ) {
echo ”

    “;
    while ( $the_query->have_posts() ) {
    $the_query->the_post();
    $date = get_the_date( $d );
    if (!in_array($date, $arr_dates_events))
    {
    $arr_dates_events[] = $date;
    };
    $month= substr($date, 5, 2);
    $month_name = $months[$month ];
    $day= substr($date, 7, 2);
    $year = substr($date, 0, 4);
    $check = array_key_exists($year, $array);
    $c = get_the_category( );
    $cat_output = array_map(function ($obj) { return $obj->cat_name; }, $c);
    $cat_output = array_intersect($cat_output, $post_allowed);
    $cat_output = array_unique ( array_map( $substr, $cat_output ) );
    $cat_output = array_intersect($properOrderedArray,$cat_output);
    if (in_array(“T”, $cat_output)) { ++$T; }
    if (in_array(“A”, $cat_output)) { ++$A; }
    if (in_array(“V”, $cat_output)) { ++$V; }
    if (in_array(“Y”, $cat_output)) { ++$Y; }
    if (in_array(“S”, $cat_output)) { ++$S; }
    if (in_array(“R”, $cat_output)) { ++$R; }
    if ( in_array(“V”, $cat_output) or in_array(“A”, $cat_output) ) { ++$M; }
    $array[$year] = 1;
    ++$count;
    if ($check === FALSE) {
    echo ”

  • $year

  • “;
    }

    echo ‘

  • ‘ . $year . ‘-‘ . $month . $day . ‘‘ . get_the_title() . ‘‘ . ‘ [‘ .implode(‘, ‘, $cat_output) . ‘]
  • ‘ ;
    }
    echo ‘

‘;

} else {
echo ‘no posts’;
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
?>