diff --git a/functions.php b/functions.php
index df0e2bd..ccbbec1 100644
--- a/functions.php
+++ b/functions.php
@@ -125,6 +125,258 @@ function blocksy_tainacan_get_adjacent_item_links() {
return ['next' => $next, 'previous' => $previous];
}
+
+/**
+ * Copy of blocksy original post navigation function.
+ */
+function blocksy_default_post_navigation() {
+ $next_post = apply_filters(
+ 'blocksy:post-navigation:next-post',
+ get_adjacent_post(false, '', true)
+ );
+
+ $previous_post = apply_filters(
+ 'blocksy:post-navigation:previous-post',
+ get_adjacent_post(false, '', false)
+ );
+
+ if (! $next_post && ! $previous_post) {
+ return '';
+ }
+
+ $prefix = blocksy_manager()->screen->get_prefix();
+
+ $container_class = 'post-navigation';
+
+ $container_class .= ' ' . blocksy_visibility_classes(get_theme_mod(
+ $prefix . '_post_nav_visibility',
+ [
+ 'desktop' => true,
+ 'tablet' => true,
+ 'mobile' => true,
+ ]
+ ));
+
+ $home_page_url = get_home_url();
+
+ $post_slug = get_post_type() === 'post' ? __( 'Post', 'blocksy' ) : get_post_type_object( get_post_type() )->labels->singular_name;
+ $post_slug = '' . $post_slug . '';
+
+ $has_thumb = get_theme_mod($prefix . '_has_post_nav_thumb', 'yes') === 'yes';
+
+ if ($has_thumb) {
+ $container_class .= ' has-thumbnails';
+ }
+
+ $has_title = get_theme_mod($prefix . '_has_post_nav_title', 'yes') === 'yes';
+
+ $next_post_image_output = '';
+ $previous_post_image_output = '';
+
+ if ($next_post) {
+ $next_title = '';
+
+ if ($has_title) {
+ $next_title = $next_post->post_title;
+ }
+
+ if ($has_thumb) {
+ $next_post_image_output = blocksy_image(
+ [
+ 'attachment_id' => get_post_thumbnail_id( $next_post ),
+ 'ratio' => '1/1',
+ 'inner_content' => '',
+ 'tag_name' => 'figure'
+ ]
+ );
+ }
+ }
+
+ if ($previous_post) {
+ $previous_title = '';
+ if ( $has_title ) {
+ $previous_title = $previous_post->post_title;
+ }
+
+ if ($has_thumb) {
+ $previous_post_image_output = blocksy_image(
+ [
+ 'attachment_id' => get_post_thumbnail_id( $previous_post ),
+ 'ratio' => '1/1',
+ 'inner_content' => '',
+ 'tag_name' => 'figure'
+ ]
+ );
+ }
+ }
+
+ ob_start();
+
+ ?>
+
+
+
+ screen->get_prefix();
+
+ if (get_theme_mod( $prefix . '_has_post_nav', $prefix === 'single_blog_post' ? 'yes' : 'no' ) === 'yes') {
+
+ $container_class = 'post-navigation';
+
+ $container_class .= ' ' . blocksy_visibility_classes(get_theme_mod(
+ $prefix . '_post_nav_visibility',
+ [
+ 'desktop' => true,
+ 'tablet' => true,
+ 'mobile' => true,
+ ]
+ ));
+
+ $has_thumb = get_theme_mod($prefix . '_has_post_nav_thumb', 'yes') === 'yes';
+
+ if ($has_thumb)
+ $container_class .= ' has-thumbnails';
+
+ $adjacent_links = [
+ 'next' => '',
+ 'previous' => ''
+ ];
+
+ $adjacent_links = blocksy_tainacan_get_adjacent_item_links();
+
+ $previous = $adjacent_links['previous'];
+ $next = $adjacent_links['next'];
+ }
+
+ ?>
+
+
+
+
+}
+
+/**
+ * Overrides parent theme blocksy post navigation logic to handle items navigation
+ */
+function blocksy_post_navigation() {
+
+ // This should only happen if we have Tainacan plugin installed
+ if ( defined ('TAINACAN_VERSION') ) {
+ $collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
+ $post_type = get_post_type();
+
+ // Check if we're inside the main loop in a single Post.
+ if (in_array($post_type, $collections_post_types) && is_singular() && in_the_loop() && is_main_query() ) {
+ return blocksy_tainacan_item_navigation();
+ }
+ }
+ return blocksy_default_post_navigation();
+}
+
+/**
+ * Uses Blocksy filter to customize the related posts logic on Tainacan Items page.
+ */
+function blocksy_tainacan_custom_related_posts_query( $related_posts_query ) {
+
+ // This should only happen if we have Tainacan plugin installed
+ if ( defined ('TAINACAN_VERSION') ) {
+ $collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
+ $post_type = get_post_type();
+
+ // Check if we're inside the main loop in a single Post.
+ if (in_array($post_type, $collections_post_types) && is_singular() && in_the_loop() && is_main_query() ) {
+ // In the future, we might update the related_postd_query here for Tainacan items.
+ }
+ }
+ return $related_posts_query;
+}
+add_filter( 'blocksy:related-posts:query-args', 'blocksy_tainacan_custom_related_posts_query', 10 );
+
/**
* Retrieves the current items list source link
*/
@@ -149,6 +401,7 @@ function blocksy_tainacan_get_source_item_list_url() {
*/
function blocksy_tainacan_custom_post_types_single_options( $options, $post_type, $post_type_object ) {
+ // This should only happen if we have Tainacan plugin installed
if ( defined ('TAINACAN_VERSION') ) {
$collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
@@ -183,6 +436,7 @@ add_filter( 'blocksy:custom_post_types:single-options', 'blocksy_tainacan_custom
*/
function blocksy_tainacan_custom_post_types_supported_list( $potential_post_types ) {
+ // This should only happen if we have Tainacan plugin installed
if ( defined ('TAINACAN_VERSION') ) {
return array_filter( $potential_post_types, function($post_type) {
return !in_array($post_type, [ 'tainacan-metadatum', 'tainacan-filter' ]);
@@ -197,6 +451,7 @@ add_filter( 'blocksy:custom_post_types:supported_list', 'blocksy_tainacan_custom
*/
function filter_the_content_in_the_main_loop( $content ) {
+ // This should only happen if we have Tainacan plugin installed
if ( defined ('TAINACAN_VERSION') ) {
$collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
$post_type = get_post_type();
@@ -215,6 +470,8 @@ add_filter( 'the_content', 'filter_the_content_in_the_main_loop');
* Enqueues js scripts related to swiper, only if in TainacanSingleItem pages
*/
function blocksy_tainacan_swiper_scripts() {
+
+ // This should only happen if we have Tainacan plugin installed
if ( defined ('TAINACAN_VERSION') ) {
$collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
$post_type = get_post_type();
diff --git a/template-parts/single-items-navigation.php b/template-parts/single-items-navigation.php
deleted file mode 100644
index f48dd4b..0000000
--- a/template-parts/single-items-navigation.php
+++ /dev/null
@@ -1,52 +0,0 @@
-screen->get_prefix();
-
-if (get_theme_mod( $prefix . '_has_post_nav', $prefix === 'single_blog_post' ? 'yes' : 'no' ) === 'yes') {
-
-
- $container_class = 'post-navigation';
-
- $container_class .= ' ' . blocksy_visibility_classes(get_theme_mod(
- $prefix . '_post_nav_visibility',
- [
- 'desktop' => true,
- 'tablet' => true,
- 'mobile' => true,
- ]
- ));
-
- $has_thumb = get_theme_mod($prefix . '_has_post_nav_thumb', 'yes') === 'yes';
-
- if ($has_thumb)
- $container_class .= ' has-thumbnails';
-
- $adjacent_links = [
- 'next' => '',
- 'previous' => ''
- ];
-
- $adjacent_links = blocksy_tainacan_get_adjacent_item_links();
-
- $previous = $adjacent_links['previous'];
- $next = $adjacent_links['next'];
-}
-?>
-
-
-
\ No newline at end of file