1

I am building an event calendar and trying to create a filter bu month & year. I have custom post type named "event-calendar" and need to have 5 events per row as i have them in a slider. So need to create the below structure

October 2017
  Post 1
  Post 2
  Post 3
  Post 4
  Post 5
November 2017
  Post 1
  Post 2
  Post 3
  Post 4
  Post 5
.............
January 2018
  Post 1
  Post 2
  Post 3
  Post 4
  Post 5

Tried to do with archives and custom sql query but no luck.

0

try something like

$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
    args = array(
        'orderby' => 'date',
        'order'   => 'DESC',
        'post_type' => 'event-calendar',
        'posts_per_page' => 5,
        'paged' => $paged
    );

    $query = new WP_Query( $args );

    while ($query->have_posts()){
        // do stuff
    }
  • Thank you for the snippet @Oliver adams but it is not displaying the post type posts in the way i need. – Anahit DEV Nov 2 '17 at 14:17
  • hey @Oliver adams that is not the thing. I updated the post type to be mine but it not showing anything and the page is being in endless loop/load. – Anahit DEV Nov 3 '17 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.