diff --git a/src/classes/class-tainacan-search-engine.php b/src/classes/class-tainacan-search-engine.php index 438ebcfb0..2dd943691 100644 --- a/src/classes/class-tainacan-search-engine.php +++ b/src/classes/class-tainacan-search-engine.php @@ -329,14 +329,14 @@ class Search_Engine { $searchand = ''; $searchSlug = ''; foreach ( $search_terms as $term ) { - $term = $wpdb->prepare("%s", $exact ? $term : "%". sanitize_title_with_dashes($term) . "%"); - $searchSlug .= "{$searchand}(tter.slug LIKE $term)"; + $term = $wpdb->prepare("%s", $exact ? $term : "%". $term . "%"); + $searchSlug .= "{$searchand}(tter.name LIKE $term)"; $searchand = ' AND '; } - $term = $wpdb->prepare("%s", $exact ? $term : "%". sanitize_title_with_dashes($s) . "%"); + $term = $wpdb->prepare("%s", $exact ? $term : "%". $s . "%"); if ( count( $search_terms ) > 1 && $search_terms[0] != $s ) { - $searchSlug = "($searchSlug) OR (tter.slug LIKE $term)"; + $searchSlug = "($searchSlug) OR (tter.name LIKE $term)"; } if ( !empty( $searchSlug ) ) $search = " OR ({$searchSlug}) "; diff --git a/src/theme-helper/template-tags.php b/src/theme-helper/template-tags.php index 2822cc310..9dc6e963d 100644 --- a/src/theme-helper/template-tags.php +++ b/src/theme-helper/template-tags.php @@ -182,13 +182,17 @@ function tainacan_the_faceted_search() { $props = ' '; + $default_view_mode = apply_filters( 'tainacan-default-view-mode-for-themes', 'masonry' ); + $enabled_view_modes = apply_filters( 'tainacan-enabled-view-modes-for-themes', ['table', 'cards', 'masonry'] ); + // if in a collection page $collection_id = tainacan_get_collection_id(); if ($collection_id) { + $props .= 'collection-id="' . $collection_id . '" '; $collection = new \Tainacan\Entities\Collection($collection_id); - $props .= 'default-view-mode="' . $collection->get_default_view_mode() . '" '; - $props .= 'enabled-view-modes="' . implode(',', $collection->get_enabled_view_modes()) . '" '; + $default_view_mode = $collection->get_default_view_mode(); + $enabled_view_modes = $collection->get_enabled_view_modes(); } // if in a tainacan taxonomy @@ -197,6 +201,9 @@ function tainacan_the_faceted_search() { $props .= 'term-id="' . $term->term_id . '" '; $props .= 'taxonomy="' . $term->taxonomy . '" '; } + + $props .= 'default-view-mode="' . $default_view_mode . '" '; + $props .= 'enabled-view-modes="' . implode(',', $enabled_view_modes) . '" '; echo "
"; @@ -278,7 +285,11 @@ function tainacan_register_view_mode($slug, $args = []) { */ function tainacan_get_item($post_id = 0) { $post = get_post( $post_id ); - + + if (!$post) { + return null; + } + $theme_helper = \Tainacan\Theme_Helper::get_instance(); if (!$theme_helper->is_post_an_item($post))