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.

1 Answer 1

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
    }
2
  • Thank you for the snippet @Oliver adams but it is not displaying the post type posts in the way i need.
    – Ana DEV
    Commented Nov 2, 2017 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.
    – Ana DEV
    Commented Nov 3, 2017 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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