Uses new tainacan_get_adjacent_items function to query contextualized next and previous items.

This commit is contained in:
mateuswetah 2020-07-21 17:50:43 -03:00
parent d3d3ce363e
commit 0242e471ef
1 changed files with 42 additions and 18 deletions

View File

@ -1,12 +1,25 @@
<?php <?php
//Get the links to the Previous and Next Post if (function_exists('tainacan_get_adjacent_items')) {
$previous_link_url = get_permalink( get_previous_post() ); $adjacent_items = tainacan_get_adjacent_items();
$next_link_url = get_permalink( get_next_post() );
//Get the title of the previous post and next post if ($adjacent_items['next']) {
$previous_title = get_the_title( get_previous_post() ); $next_link_url = $adjacent_items['next']['url'];
$next_title = get_the_title( get_next_post() ); $next_title = $adjacent_items['next']['title'];
}
if ($adjacent_items['previous']) {
$previous_link_url = $adjacent_items['previous']['url'];
$previous_title = $adjacent_items['previous']['title'];
}
} else {
//Get the links to the Previous and Next Post
$previous_link_url = get_permalink( get_previous_post() );
$next_link_url = get_permalink( get_next_post() );
//Get the title of the previous post and next post
$previous_title = get_the_title( get_previous_post() );
$next_title = get_the_title( get_next_post() );
}
$previous = ''; $previous = '';
$next = ''; $next = '';
@ -20,8 +33,17 @@
case 'thumbnail_small': case 'thumbnail_small':
//Get the thumnail url of the previous and next post //Get the thumnail url of the previous and next post
$previous_thumb = get_the_post_thumbnail_url( get_previous_post(), 'tainacan-small' ); if (function_exists('tainacan_get_adjacent_items')) {
$next_thumb = get_the_post_thumbnail_url( get_next_post(), 'tainacan-small' ); if ($adjacent_items['next']) {
$next_thumb = $adjacent_items['next']['thumbnail']['tainacan-small'][0];
}
if ($adjacent_items['previous']) {
$previous_thumb = $adjacent_items['previous']['thumbnail']['tainacan-small'][0];
}
} else {
$previous_thumb = get_the_post_thumbnail_url( get_previous_post(), 'tainacan-small' );
$next_thumb = get_the_post_thumbnail_url( get_next_post(), 'tainacan-small' );
}
// Creates the links // Creates the links
$previous = $previous =
@ -37,17 +59,19 @@
break; break;
case 'thumbnail_large': case 'thumbnail_large':
//Get the thumnail url of the previous and next post
$previous_thumb = get_the_post_thumbnail_url( get_previous_post(), 'tainacan-medium' );
$next_thumb = get_the_post_thumbnail_url( get_next_post(), 'tainacan-medium' );
//Get the links to the Previous and Next Post if (function_exists('tainacan_get_adjacent_items')) {
$previous_link_url = get_permalink( get_previous_post() ); if ($adjacent_items['next']) {
$next_link_url = get_permalink( get_next_post() ); $next_thumb = $adjacent_items['next']['thumbnail']['tainacan-medium'][0];
}
//Get the title of the previous post and next post if ($adjacent_items['previous']) {
$previous_title = get_the_title( get_previous_post() ); $previous_thumb = $adjacent_items['previous']['thumbnail']['tainacan-medium'][0];
$next_title = get_the_title( get_next_post() ); }
} else {
//Get the thumnail url of the previous and next post
$previous_thumb = get_the_post_thumbnail_url( get_previous_post(), 'tainacan-medium' );
$next_thumb = get_the_post_thumbnail_url( get_next_post(), 'tainacan-medium' );
}
// Creates the links // Creates the links
$previous = $previous =