Test


get_var($total_query);

$page = isset( $_GET[‘cpage’] ) ? abs( (int) $_GET[‘cpage’] ) : 1;
$offset = ($page * $papers_per_page) – $papers_per_page;
$papers_to_show = $wpdb->get_results($query . ” LIMIT ${offset}, ${papers_per_page}”);

$year = 2050;

foreach ($papers_to_show as $paper) {
$p_title = $paper->title;
$p_authors = $paper->authors;
$p_ref = $paper->citation;
$p_url = $paper->url;
$p_date = $paper->publication_date;
$p_year = date(‘Y’,strtotime($p_date));

if ($p_year < $year) {
$year = $p_year;
echo ‘

‘.$year.’

‘;
}

if ($p_url == “”){
echo ‘

‘.$p_title.’
‘.$p_authors.’
‘.$p_ref.’

‘;
} else {
echo ‘

‘.$p_title.’
‘.$p_authors.’
‘.$p_ref.’

‘;
}
}

echo ”

“;
echo paginate_links( array(
‘base’ => add_query_arg( ‘cpage’, ‘%#%’ ),
‘format’ => ‘?paged=%#%’,
‘prev_text’ => __(‘«’),
‘next_text’ => __(‘»’),
‘total’ => ceil($total_papers / $papers_per_page),
‘current’ => $page,
‘type’ => ‘plain’
));
echo “

“;
}
?>