generated from pascalmartineau/wp-skeleton
fix: Breadcrumbs
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 59s
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 59s
This commit is contained in:
@@ -5,10 +5,9 @@ useSeoMeta({ title: node?.title });
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="">
|
||||
<pre>{{ breadcrumbs }}</pre>
|
||||
<UContainer>
|
||||
<UBreadcrumb :items="breadcrumbs" />
|
||||
</div>
|
||||
</UContainer>
|
||||
<component :is="component" :node="node" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -50,7 +50,7 @@ function ccat_get_breadcrumbs( $node ) {
|
||||
if ( $post ) {
|
||||
$breadcrumbs = ccat_get_post_breadcrumbs( $post );
|
||||
$breadcrumbs[] = array(
|
||||
'label' => get_the_title( $post->ID ),
|
||||
'label' => html_entity_decode( get_the_title( $post->ID ), ENT_QUOTES, 'UTF-8' ),
|
||||
'uri' => null,
|
||||
);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ function ccat_get_breadcrumbs( $node ) {
|
||||
if ( $term && ! is_wp_error( $term ) ) {
|
||||
$breadcrumbs = ccat_get_term_breadcrumbs( $term );
|
||||
$breadcrumbs[] = array(
|
||||
'label' => $term->name,
|
||||
'label' => html_entity_decode( $term->name, ENT_QUOTES, 'UTF-8' ),
|
||||
'uri' => null,
|
||||
);
|
||||
}
|
||||
@@ -70,6 +70,15 @@ function ccat_get_breadcrumbs( $node ) {
|
||||
// Helper: Get breadcrumbs for a given post
|
||||
function ccat_get_post_breadcrumbs( $post ) {
|
||||
$breadcrumbs = array();
|
||||
$is_front_page = get_option( 'show_on_front' ) === 'page' && get_option( 'page_on_front' ) == $post->ID;
|
||||
if ( $is_front_page ) {
|
||||
return $breadcrumbs; // No breadcrumbs for the front page
|
||||
} else {
|
||||
$breadcrumbs[] = array(
|
||||
'label' => 'Accueil',
|
||||
'uri' => '/',
|
||||
);
|
||||
}
|
||||
$post_type = get_post_type( $post->ID );
|
||||
switch ( $post_type ) {
|
||||
case 'page':
|
||||
|
||||
Reference in New Issue
Block a user