Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $args = array(
- 'post_type' => 'auction_dates',
- 'paged' => $paged,
- 'posts_per_page' => 1,
- 'meta_key' => 'date_of_auction',
- 'orderby' => 'meta_value_num',
- 'order' => 'ASC');
- $previous_adjacent_post = get_adjacent_post(true,'',true, 'product_cat');
- $next_adjacent_post = get_adjacent_post(true,'',false, 'product_cat');
- if(is_a($previous_adjacent_post, 'WP_Post')){
- $previous_link = get_permalink($previous_adjacent_post->ID);
- $previous_title = $previous_adjacent_post->post_title;
- }
- if(is_a($next_adjacent_post, 'WP_Post')){
- $next_link = get_permalink($next_adjacent_post->ID);
- $next_title = $next_adjacent_post->post_title;
- }
- <?php next_post_link_plus( array('in_same_meta' => 'publisher') ); ?>
- function get_adjacent_posts($args) {
- global $post;
- $all_posts = get_posts($args);
- $len = count($all_posts);
- $np = null;
- $cp = $post;
- $pp = null;
- if ($len > 1) {
- for ($i=0; $i < $len; $i++) {
- if ($all_posts[$i]->ID === $cp->ID) {
- if (array_key_exists($i-1, $all_posts)) {
- $pp = $all_posts[$i-1];
- } else {
- $new_key = $len-1;
- $pp = $all_posts[$new_key];
- while ($pp->ID === $cp->ID) {
- $new_key -= 1;
- $pp = $all_posts[$new_key];
- }
- }
- if (array_key_exists($i+1, $all_posts)) {
- $np = $all_posts[$i+1];
- } else {
- $new_key = 0;
- $np = $all_posts[$new_key];
- while ($pp->ID === $cp->ID) {
- $new_key += 1;
- $np = $all_posts[$new_key];
- }
- }
- break;
- }
- }
- }
- return array('next' => $np, 'prev' => $pp);
- }
- $args = array(
- 'post_type' => 'custom_post_type',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'title'
- );
- $adjacent = get_adjacent_posts($args);
- $next_title = $adjacent['next']->post_title;
- $next_image = get_the_post_thumbnail_url($adjacent['next']->ID, 'square');
- $next_url = get_permalink($adjacent['next']);
- $prev_title = $adjacent['prev']->post_title;
- $prev_image = get_the_post_thumbnail_url($adjacent['next']->ID, 'square');
- $prev_url = get_permalink($adjacent['prev']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement