Fixes to breadcrumb representation of taxonomies path.

This commit is contained in:
mateuswetah 2023-03-10 10:13:34 -03:00
parent 11172a861e
commit 5a6c7978d0
3 changed files with 23 additions and 12 deletions

View File

@ -242,6 +242,7 @@ function tainacan_include_items_in_search_results( $query ) {
if ( !is_post_type_archive() && isset($_GET['s']) ) { if ( !is_post_type_archive() && isset($_GET['s']) ) {
if ( defined ('TAINACAN_VERSION') && if ( defined ('TAINACAN_VERSION') &&
$query->get( 'post_type' ) !== 'tainacan-collection' && $query->get( 'post_type' ) !== 'tainacan-collection' &&
$query->get( 'post_type' ) !== 'tainacan-taxonomy' &&
(!isset($_GET['onlyposts']) || !$_GET['onlyposts']) && (!isset($_GET['onlyposts']) || !$_GET['onlyposts']) &&
(!isset($_GET['onlypages']) || !$_GET['onlypages']) && (!isset($_GET['onlypages']) || !$_GET['onlypages']) &&
$query->is_main_query() && $query->is_main_query() &&
@ -254,7 +255,7 @@ function tainacan_include_items_in_search_results( $query ) {
if ( !is_array($existing_post_types) ) if ( !is_array($existing_post_types) )
$existing_post_types = [ $existing_post_types ]; $existing_post_types = [ $existing_post_types ];
$query->set( 'post_type', array_merge( $existing_post_types, ['post', 'page', 'tainacan-collection'], $collections_post_types ) ); $query->set( 'post_type', array_merge( $existing_post_types, ['post', 'page', 'tainacan-collection', 'tainacan-taxonomy'], $collections_post_types ) );
} else if ( isset($_GET['onlypages']) && $_GET['onlypages'] && $query->is_main_query() && $query->is_search() && ! is_admin() ) { } else if ( isset($_GET['onlypages']) && $_GET['onlypages'] && $query->is_main_query() && $query->is_search() && ! is_admin() ) {
$query->set( 'post_type', 'pages' ); $query->set( 'post_type', 'pages' );
} else if ( isset($_GET['onlyposts']) && $_GET['onlyposts'] && $query->is_main_query() && $query->is_search() && ! is_admin() ) { } else if ( isset($_GET['onlyposts']) && $_GET['onlyposts'] && $query->is_main_query() && $query->is_search() && ! is_admin() ) {

View File

@ -25,6 +25,14 @@ function tainacan_theme_collection_title( $title ) {
} }
add_filter( 'get_the_archive_title', 'tainacan_theme_collection_title' ); add_filter( 'get_the_archive_title', 'tainacan_theme_collection_title' );
function tainacan_theme_taxonomy_title( $title ) {
if ( is_post_type_archive( 'tainacan-taxononomy' ) ) {
return __( 'Taxonomies', 'tainacan-interface' );
}
return $title;
}
add_filter( 'get_the_archive_title', 'tainacan_theme_taxonomy_title' );
function tainacan_theme_collection_query( $query ) { function tainacan_theme_collection_query( $query ) {
if ( $query->is_main_query() && $query->is_post_type_archive( 'tainacan-collection' ) ) { if ( $query->is_main_query() && $query->is_post_type_archive( 'tainacan-collection' ) ) {
$query->set( 'posts_per_page', 12 ); $query->set( 'posts_per_page', 12 );

View File

@ -43,7 +43,7 @@ function tainacan_interface_the_breadcrumb() {
if ( get_post_type() != 'post' ) { if ( get_post_type() != 'post' ) {
$post_type = get_post_type_object(get_post_type()); $post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite; $slug = $post_type->rewrite;
if(!is_page() && get_post_type() != 'tainacan-collection') { if (!is_page() && get_post_type() != 'tainacan-collection' && get_post_type() != 'tainacan-taxonomy' ) {
echo '<a href="'. esc_url(get_post_type_archive_link('tainacan-collection')) .'">'; _e( 'Collections', 'tainacan-interface' ); echo '</a>&nbsp;' . $delimiter . '&nbsp;'; echo '<a href="'. esc_url(get_post_type_archive_link('tainacan-collection')) .'">'; _e( 'Collections', 'tainacan-interface' ); echo '</a>&nbsp;' . $delimiter . '&nbsp;';
} }
echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>'; echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>';
@ -83,7 +83,7 @@ function tainacan_interface_the_breadcrumb() {
// Display the current term in the breadcrumb // Display the current term in the breadcrumb
echo '&nbsp;' . $delimiter . '&nbsp;'; echo '&nbsp;' . $delimiter . '&nbsp;';
echo $before . $term->name . $after; echo $before . $term->name . $after;
} elseif(!is_tax() && get_post_type() != 'tainacan-collection') { } elseif( !is_tax() && get_post_type() != 'tainacan-collection' && get_post_type() != 'tainacan-taxonomy' ) {
echo '<a href="'. esc_url(get_post_type_archive_link('tainacan-collection') ) .'">'; echo '<a href="'. esc_url(get_post_type_archive_link('tainacan-collection') ) .'">';
_e( 'Collections', 'tainacan-interface' ); _e( 'Collections', 'tainacan-interface' );
echo '</a>&nbsp;' . $delimiter . '&nbsp;'; echo '</a>&nbsp;' . $delimiter . '&nbsp;';
@ -97,8 +97,10 @@ function tainacan_interface_the_breadcrumb() {
} }
echo $before . $str . $after; echo $before . $str . $after;
} else { } else {
if ( is_archive() ) { if ( is_archive() && get_post_type() == 'tainacan-collection' ) {
$str = __( 'Collections', 'tainacan-interface' ) . '&nbsp;'; $str = __( 'Collections', 'tainacan-interface' ) . '&nbsp;';
} else if ( is_archive() && get_post_type() == 'tainacan-taxonomy' ) {
$str = __( 'Taxonomies', 'tainacan-interface' ) . '&nbsp;';
} else { } else {
$str = $post_type->labels->singular_name; $str = $post_type->labels->singular_name;
} }