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>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="">
|
<UContainer>
|
||||||
<pre>{{ breadcrumbs }}</pre>
|
|
||||||
<UBreadcrumb :items="breadcrumbs" />
|
<UBreadcrumb :items="breadcrumbs" />
|
||||||
</div>
|
</UContainer>
|
||||||
<component :is="component" :node="node" />
|
<component :is="component" :node="node" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function ccat_get_breadcrumbs( $node ) {
|
|||||||
if ( $post ) {
|
if ( $post ) {
|
||||||
$breadcrumbs = ccat_get_post_breadcrumbs( $post );
|
$breadcrumbs = ccat_get_post_breadcrumbs( $post );
|
||||||
$breadcrumbs[] = array(
|
$breadcrumbs[] = array(
|
||||||
'label' => get_the_title( $post->ID ),
|
'label' => html_entity_decode( get_the_title( $post->ID ), ENT_QUOTES, 'UTF-8' ),
|
||||||
'uri' => null,
|
'uri' => null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ function ccat_get_breadcrumbs( $node ) {
|
|||||||
if ( $term && ! is_wp_error( $term ) ) {
|
if ( $term && ! is_wp_error( $term ) ) {
|
||||||
$breadcrumbs = ccat_get_term_breadcrumbs( $term );
|
$breadcrumbs = ccat_get_term_breadcrumbs( $term );
|
||||||
$breadcrumbs[] = array(
|
$breadcrumbs[] = array(
|
||||||
'label' => $term->name,
|
'label' => html_entity_decode( $term->name, ENT_QUOTES, 'UTF-8' ),
|
||||||
'uri' => null,
|
'uri' => null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -70,6 +70,15 @@ function ccat_get_breadcrumbs( $node ) {
|
|||||||
// Helper: Get breadcrumbs for a given post
|
// Helper: Get breadcrumbs for a given post
|
||||||
function ccat_get_post_breadcrumbs( $post ) {
|
function ccat_get_post_breadcrumbs( $post ) {
|
||||||
$breadcrumbs = array();
|
$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 );
|
$post_type = get_post_type( $post->ID );
|
||||||
switch ( $post_type ) {
|
switch ( $post_type ) {
|
||||||
case 'page':
|
case 'page':
|
||||||
|
|||||||
Reference in New Issue
Block a user