function sommaire_article_shortcode() {
    if (!is_singular()) return '';

    global $post;

    // IMPORTANT : récupérer le contenu FINAL
    $content = apply_filters('the_content', $post->post_content);

    // Récupérer les H2 à H4 (évite H1 souvent inutile)
    preg_match_all('/<h([2-4])[^>]*>(.*?)<\/h\1>/i', $content, $matches);

    if (empty($matches[0])) {
        return '<p>Aucun titre trouvé.</p>';
    }

    $output = '<div class="sommaire"><ul>';

    foreach ($matches[0] as $index => $heading) {
        $level = $matches[1][$index];
        $text  = strip_tags($matches[2][$index]);

        $id = sanitize_title($text);

        $output .= '<li class="niveau-'.$level.'">
                        <a href="#'.$id.'">'.$text.'</a>
                    </li>';
    }

    $output .= '</ul></div>';

    return $output;
}

add_shortcode('sommaire', 'sommaire_article_shortcode');<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//comparatif-hebergeur-web.fr/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://comparatif-hebergeur-web.fr/post-sitemap.xml</loc>
		<lastmod>2026-04-27T18:35:14+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://comparatif-hebergeur-web.fr/page-sitemap.xml</loc>
		<lastmod>2026-04-27T18:52:09+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://comparatif-hebergeur-web.fr/avis-sitemap.xml</loc>
		<lastmod>2026-02-18T06:23:26+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://comparatif-hebergeur-web.fr/category-sitemap.xml</loc>
		<lastmod>2026-04-27T18:35:14+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://comparatif-hebergeur-web.fr/author-sitemap.xml</loc>
		<lastmod>2026-02-04T16:50:26+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->