Skip to main content
added 36 characters in body
Source Link
kaiser
  • 50.8k
  • 27
  • 150
  • 244

The function get_event_list()get_event_list()

Should looks like this …

Whenever you use a custom query you must include paged variable in the query for pagination to work.

Pagination Note: Use get_query_var('page');get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The query variable 'page''page' also holds the pagenumber for a single paginated Post or Page that includes the Quicktag<!--nextpage--> Quicktag in the post content.

Important link:    httpWP_Query://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters 

function get_event_list( $latest = true, $order = 'ASC' ) { echo '';

function get_event_list( $latest = true, $order = 'ASC' ) {
    echo '<ul class="event-items">';

    global $paged; // paged variable
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // set paged
    $yesterday = time() - 24*60*60;
    $compare = $latest ? '>' : '<';

    $args = array(
        'post_type' => 'wr_event',
        'posts_per_page' => 'posts_per_page' => is_archive() ? 16 : -1,
        'meta_key' => 'event_date',
        'orderby' => 'meta_value_num',
        'order' => $order,
        'meta_value' => $yesterday,
        'meta_compare' => $compare,
        'paged' => $paged           // add paged variable in argument array
    );

    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
        get_template_part( 'inc/event', 'item' );
    endwhile;
    wp_reset_postdata();
    echo '</ul>';
}

}

The function get_event_list()

Should looks like this …

Whenever you use a custom query you must include paged variable in the query for pagination to work.

Pagination Note: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The query variable 'page' also holds the pagenumber for a single paginated Post or Page that includes the Quicktag in the post content.

Important link:  http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

function get_event_list( $latest = true, $order = 'ASC' ) { echo '';

global $paged; // paged variable
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // set paged
$yesterday = time() - 24*60*60;
$compare = $latest ? '>' : '<';

$args = array(
    'post_type' => 'wr_event',
    'posts_per_page' => 'posts_per_page' => is_archive() ? 16 : -1,
    'meta_key' => 'event_date',
    'orderby' => 'meta_value_num',
    'order' => $order,
    'meta_value' => $yesterday,
    'meta_compare' => $compare,
    'paged' => $paged           // add paged variable in argument array
);

$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
    get_template_part( 'inc/event', 'item' );
endwhile;
wp_reset_postdata();
echo '</ul>';

}

The function get_event_list()

Should looks like this …

Whenever you use a custom query you must include paged variable in the query for pagination to work.

Pagination Note: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The query variable 'page' also holds the pagenumber for a single paginated Post or Page that includes the <!--nextpage--> Quicktag in the post content.

Important link:  WP_Query: 

function get_event_list( $latest = true, $order = 'ASC' ) {
    echo '<ul class="event-items">';

    global $paged; // paged variable
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // set paged
    $yesterday = time() - 24*60*60;
    $compare = $latest ? '>' : '<';

    $args = array(
        'post_type' => 'wr_event',
        'posts_per_page' => 'posts_per_page' => is_archive() ? 16 : -1,
        'meta_key' => 'event_date',
        'orderby' => 'meta_value_num',
        'order' => $order,
        'meta_value' => $yesterday,
        'meta_compare' => $compare,
        'paged' => $paged           // add paged variable in argument array
    );

    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
        get_template_part( 'inc/event', 'item' );
    endwhile;
    wp_reset_postdata();
    echo '</ul>';
}
Source Link

The function get_event_list()

Should looks like this …

Whenever you use a custom query you must include paged variable in the query for pagination to work.

Pagination Note: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The query variable 'page' also holds the pagenumber for a single paginated Post or Page that includes the Quicktag in the post content.

Important link: http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

function get_event_list( $latest = true, $order = 'ASC' ) { echo '';

global $paged; // paged variable
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // set paged
$yesterday = time() - 24*60*60;
$compare = $latest ? '>' : '<';

$args = array(
    'post_type' => 'wr_event',
    'posts_per_page' => 'posts_per_page' => is_archive() ? 16 : -1,
    'meta_key' => 'event_date',
    'orderby' => 'meta_value_num',
    'order' => $order,
    'meta_value' => $yesterday,
    'meta_compare' => $compare,
    'paged' => $paged           // add paged variable in argument array
);

$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
    get_template_part( 'inc/event', 'item' );
endwhile;
wp_reset_postdata();
echo '</ul>';

}