working on bradcrumbs and internal links
This commit is contained in:
parent
f22ffdde58
commit
4f6aee68e0
|
|
@ -15,4 +15,3 @@ require_once(__DIR__ . '/includes/templates.php');
|
|||
require_once(__DIR__ . '/includes/ajax.php');
|
||||
|
||||
// require_once(__DIR__ . '/includes/widget.php');
|
||||
// require_once( __DIR__ . '/includes/logos.php');
|
||||
|
|
@ -1,19 +1,6 @@
|
|||
<?php
|
||||
|
||||
|
||||
|
||||
/* ------------------------------
|
||||
ENABLE SVG
|
||||
------------------------------*/
|
||||
|
||||
|
||||
function cc_mime_types($mimes)
|
||||
{
|
||||
$mimes['svg'] = 'image/svg+xml';
|
||||
return $mimes;
|
||||
}
|
||||
add_filter('upload_mimes', 'cc_mime_types');
|
||||
|
||||
/* ---------------------------
|
||||
PAGE D'OPTIONS DU THEME
|
||||
---------------------------*/
|
||||
|
|
|
|||
|
|
@ -50,6 +50,20 @@ function getParentThematique($thematique)
|
|||
}
|
||||
}
|
||||
|
||||
// DOES THE SAME THING AS ABOVE BUT RENAMED
|
||||
function getMainThematique($thematique)
|
||||
{
|
||||
if (!$thematique) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($thematique->parent == 0) {
|
||||
return $thematique;
|
||||
} else {
|
||||
return get_term($thematique->parent, 'thematiques');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get automatic post used in BLOCK QUESTIONS FREQUENTES
|
||||
function get_automatic_post($post_type)
|
||||
|
|
@ -62,3 +76,14 @@ function get_automatic_post($post_type)
|
|||
);
|
||||
return get_posts($automatic_query_args)[0];
|
||||
}
|
||||
|
||||
|
||||
// TO GET ARCHIVE RELATED PAGES BY TEMPLATE
|
||||
function get_page_by_template($template = '')
|
||||
{
|
||||
$args = array(
|
||||
'meta_key' => '_wp_page_template',
|
||||
'meta_value' => $template
|
||||
);
|
||||
return get_pages($args);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,45 +34,77 @@ function build_chapter_index($blocks)
|
|||
<?php if (have_posts()) : ?>
|
||||
<?php while (have_posts()) : the_post(); ?>
|
||||
<?php
|
||||
$thematique = get_the_terms(get_the_ID(), 'thematiques')[0];
|
||||
$thematiqueParent = getParentThematique($thematique);
|
||||
// $thematiqueColorSlug = getThematiqueFamilySlug($thematiqueParent->slug);
|
||||
$thematiqueColorSlug = $thematiqueParent->slug;
|
||||
$currentThematique = get_the_terms(get_the_ID(), 'thematiques')[0];
|
||||
$mainThematique = getMainThematique($currentThematique);
|
||||
$thematiqueColorSlug = $mainThematique->slug;
|
||||
?>
|
||||
|
||||
<div class="post-conseil-page-container <?php echo $thematiqueColorSlug ? "post-conseil-page--" . $thematiqueColorSlug : "" ?>"">
|
||||
<nav class=" breadcrumbs_navigation" aria-label="breadcrumbs">
|
||||
<?php
|
||||
$archiveConseils = get_page_by_template('template-archive-conseils.php')[0];
|
||||
|
||||
|
||||
?>
|
||||
<ol>
|
||||
<li><a href="<?php echo home_url() ?>">Home</a></li>
|
||||
<li><a href="<?php echo get_post_permalink($archiveConseils) ?>"><?php echo $archiveConseils->post_title ?></a></li>
|
||||
<?php if ($mainThematique != $currentThematique) : ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'conseils', // the post type
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'thematiques', // the custom vocabulary
|
||||
'field' => 'term_id', // term_id, slug or name
|
||||
'terms' => array($mainThematique->term_id),
|
||||
'include_children' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
$mainThematiqueRelatedConseil = get_posts($args)[0] ?? null;
|
||||
?>
|
||||
<li><a href="<?php echo get_post_permalink($mainThematiqueRelatedConseil) ?>"><?php echo $mainThematique->name ?></a></li>
|
||||
|
||||
<?php endif; ?>
|
||||
<li><a href="<?php echo the_permalink() ?>" aria-current="location"><?php echo $currentThematique->name ?></a></li>
|
||||
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<?php
|
||||
$blocks = parse_blocks($post->post_content);
|
||||
$chapterBlockIndex = build_chapter_index($blocks);
|
||||
?>
|
||||
<?php get_template_part('template-components/post-conseils/chapter-header'); ?>
|
||||
<div class=" conseils_wrapper">
|
||||
<?php if ($chapterBlockIndex) : ?>
|
||||
<aside class="chapter_index">
|
||||
<div class="chapter_index__titling">
|
||||
<div class="icon"></div>
|
||||
<h2 class="chapter_index__title">Dans ce conseil</h2>
|
||||
</div>
|
||||
<ul class="chapter_index__list">
|
||||
<div class="chapter_index__position-indicator"></div>
|
||||
<?php foreach ($chapterBlockIndex as $chapter) : ?>
|
||||
<li class="chapter_index__link"><a href="<?php echo $chapter['anchor'] ?>"><?php echo $chapter['title'] ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</aside>
|
||||
<?php endif; ?>
|
||||
<?php if ($chapterBlockIndex) : ?>
|
||||
<aside class="chapter_index">
|
||||
<div class="chapter_index__titling">
|
||||
<div class="icon"></div>
|
||||
<h2 class="chapter_index__title">Dans ce conseil</h2>
|
||||
</div>
|
||||
<ul class="chapter_index__list">
|
||||
<div class="chapter_index__position-indicator"></div>
|
||||
<?php foreach ($chapterBlockIndex as $chapter) : ?>
|
||||
<li class="chapter_index__link"><a href="<?php echo $chapter['anchor'] ?>"><?php echo $chapter['title'] ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</aside>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- CHAPTER INDEX -->
|
||||
<!-- CHAPTER INDEX -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<article class="entry-content single-editor-content <?php echo $thematiqueColorSlug ? "entry-content--" . $thematiqueColorSlug : "" ?>">
|
||||
<?php the_content() ?>
|
||||
</article>
|
||||
<article class="entry-content single-editor-content <?php echo $thematiqueColorSlug ? "entry-content--" . $thematiqueColorSlug : "" ?>">
|
||||
<?php the_content() ?>
|
||||
</article>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@ $thematiqueColorSlug = getThematiqueFamilySlug($thematique_generale->slug);
|
|||
|
||||
$current_children_thematique = get_queried_object()->parent != 0 ? get_queried_object() : null;
|
||||
|
||||
echo '<pre>';
|
||||
print_r($thematiqueColorSlug);
|
||||
echo '</pre>';
|
||||
|
||||
|
||||
$args = array(
|
||||
'posts_per_page' => 1,
|
||||
|
|
@ -28,35 +24,19 @@ $args = array(
|
|||
$query_current_thematique_posts = new WP_Query($args);
|
||||
$thematique_related_page = $query_current_thematique_posts->posts[0];
|
||||
|
||||
echo '<pre>';
|
||||
// print_r($term);
|
||||
// print_r($term_test);
|
||||
// print_r($query_current_thematique_posts->posts);
|
||||
// print_r($thematique_related_page);
|
||||
// print_r($current_children_thematique);
|
||||
// print_r($current_thematique);
|
||||
// print_r(is_tax('thematiques', 'thematiques'));
|
||||
echo '</pre>';
|
||||
|
||||
|
||||
$test = get_term_by('id', 12, 'category');
|
||||
|
||||
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($thematique_related_page);
|
||||
// echo '</pre>';
|
||||
|
||||
|
||||
// echo $the_query->posts[0]->post_content;
|
||||
$archiveQuestions = get_page_by_template('template-archive-questions.php')[0];
|
||||
?>
|
||||
<div class="breadcrumb-thematiques">
|
||||
<ul>
|
||||
|
||||
|
||||
<nav class="breadcrumbs_navigation" aria-label="breadcrumbs">
|
||||
<ol>
|
||||
<li><a href="<?php echo home_url() ?>">Home</a></li>
|
||||
<li><a href="<?php echo get_post_permalink($archiveQuestions) ?>"><?php echo $archiveQuestions->post_title ?></a></li>
|
||||
|
||||
<li>
|
||||
<a href="">Home ></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo get_term_link($thematique_generale) ?>"><?php echo $thematique_generale->name ?></a>
|
||||
<a href="<?php echo get_term_link($thematique_generale) ?>" aria-current='location'><?php echo $thematique_generale->name ?></a>
|
||||
</li>
|
||||
<?php if ($current_children_thematique) : ?>
|
||||
<li>
|
||||
|
|
@ -64,10 +44,8 @@ $test = get_term_by('id', 12, 'category');
|
|||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div class="list_filters">
|
||||
<?php if ($thematique->parent) : ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user