fix: Breadcrumbs
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 59s

This commit is contained in:
2025-09-15 15:48:42 -04:00
parent ff5cc82384
commit 28186c9141
2 changed files with 15 additions and 7 deletions

View File

@@ -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>

View File

@@ -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,
);
}
@@ -69,8 +69,17 @@ function ccat_get_breadcrumbs( $node ) {
// Helper: Get breadcrumbs for a given post
function ccat_get_post_breadcrumbs( $post ) {
$breadcrumbs = array();
$post_type = get_post_type( $post->ID );
$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':
$ancestors = get_post_ancestors( $post->ID );