i changed the code from above to this:
function get_prev_post_by_cat($link="? %link", $title="%title") {
global $wpdb, $post;
$offset = ($paged-1) * $postsperpage;
$prev = $wpdb->get_row($wpdb->prepare("SELECT
wp_terms.name,
wp_posts.post_title,
wp_posts.post_date
FROM wp_posts
LEFT JOIN wp_term_relationships
ON wp_term_relationships.object_id = wp_posts.ID
LEFT JOIN wp_term_taxonomy
ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id
LEFT JOIN wp_terms
ON wp_terms.term_id = wp_term_taxonomy.term_id
WHERE wp_term_taxonomy.taxonomy = 'category'
ORDER BY wp_terms.name, wp_posts.post_date DESC LIMIT $offset;"));
if($prev) {
$title = preg_replace('/%title/',$prev->post_title, $title);
echo preg_replace('/%link/', '<a href="'.get_permalink($prev->ID).'" rel="prev">'.$title.'</a>', $link);
}
}
function get_next_post_by_cat($link="%link ?", $title="%title") {
global $wpdb, $post;
$offset = ($paged-1) * $postsperpage;
$next = $wpdb->get_row($wpdb->prepare("SELECT
wp_terms.name,
wp_posts.post_title,
wp_posts.post_date
FROM wp_posts
LEFT JOIN wp_term_relationships
ON wp_term_relationships.object_id = wp_posts.ID
LEFT JOIN wp_term_taxonomy
ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id
LEFT JOIN wp_terms
ON wp_terms.term_id = wp_term_taxonomy.term_id
WHERE wp_term_taxonomy.taxonomy = 'category'
ORDER BY wp_terms.name, wp_posts.post_date ASC LIMIT $offset ;"));
if($next) {
$title = preg_replace('/%title/',$next->post_title, $title);
echo preg_replace('/%link/', '<a href="'.get_permalink($next->ID).'" rel="next">'.$title.'</a>', $link);
}
}
but i think i have to include an offset parameter somehow?