', $afterGroup='', $beforeEach='
  • ', $afterEach='
  • ', $showtitle=true, $textForEach='Previous post in %:
    ') { global $wpdb, $post; // get home url for base of link $info = get_bloginfo('url'); $info = apply_filters('bloginfo', $info); $homeurl = convert_chars($info); // get post id of current post $currentPostId = $post->ID; // get post date of current post $currentPostDate = $post->post_date; // get the catagorys this post uses. $catagoryIds = get_the_category(); $startGroup = true; foreach ($catagoryIds as $currentCat) { // HEAVY LIFTING! Getting the prevous post. Ugh. $newPostInfo = $wpdb->get_row( "SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id = $currentCat->cat_ID AND $wpdb->posts.post_date < '$currentPostDate' ORDER BY post_date DESC LIMIT 1"); if ($newPostInfo) { $leaderText = str_replace('%', $currentCat->cat_name, $textForEach); if ($startGroup) { echo $beforeGroup; $startGroup = false; } if ($showtitle) { echo $beforeEach.$leaderText."ID)."\">".stripslashes($newPostInfo->post_title)."".$afterEach; } else { echo $beforeEach."ID)."\">".$leaderText."".$afterEach; } } } if (!$startGroup) { echo $afterGroup; } else { // RAM: echo None if there is nothing there. echo $beforeGroup.$beforeEach."None".$afterEach.$afterGroup; } } function next_cat_post($beforeGroup='', $beforeEach='
  • ', $afterEach='
  • ', $showtitle=true, $textForEach='Next post in %:
    ') { global $wpdb, $post; // get home url for base of link $info = get_bloginfo('url'); $info = apply_filters('bloginfo', $info); $homeurl = convert_chars($info); // get post id of current post $currentPostId = $post->ID; // get post date of current post $currentPostDate = $post->post_date; // get the catagorys this post uses. $catagoryIds = get_the_category(); $startGroup = true; foreach ($catagoryIds as $currentCat) { // HEAVY LIFTING! Getting the next post. Copy and paste of the // prvious code, but with the sort order and date comparison reversed. $newPostInfo = $wpdb->get_row( "SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id = $currentCat->cat_ID AND $wpdb->posts.post_date > '$currentPostDate' ORDER BY post_date ASC LIMIT 1"); if ($newPostInfo) { $leaderText = str_replace('%', $currentCat->cat_name, $textForEach); if ($startGroup) { echo $beforeGroup; $startGroup = false; } if ($showtitle) { echo $beforeEach.$leaderText."ID)."\">".stripslashes($newPostInfo->post_title)."".$afterEach; } else { echo $beforeEach."ID)."\">".$leaderText."".$afterEach; } } } if (!$startGroup) { echo $afterGroup; } else { // RAM: echo None if there is nothing there. echo $beforeGroup.$beforeEach."None".$afterEach.$afterGroup; } } ?>