
// POST TYPE ENRICO + 3 CAMPI ACF + VISUALIZZAZIONE

// 1. Registra Post Type
add_action('init', function() {
    register_post_type('enrico', [
        'labels' => [
            'name' => 'Enrico',
            'singular_name' => 'Enrico',
            'add_new_item' => 'Aggiungi Enrico',
        ],
        'public' => true,
        'has_archive' => true,
        'rewrite' => ['slug' => 'enrico'],
        'supports' => ['title', 'editor', 'thumbnail'],
        'menu_icon' => 'dashicons-businessman',
        'show_in_rest' => true,
    ]);
});

// 2. Registra i 3 campi ACF
add_action('acf/init', function() {
    if (!function_exists('acf_add_local_field_group')) return;

    acf_add_local_field_group([
        'key' => 'group_enrico',
        'title' => 'Dati Enrico',
        'fields' => [
            [
                'key' => 'field_nome',
                'label' => 'Nome',
                'name' => 'nome',
                'type' => 'text',
                'required' => 1,
            ],
            [
                'key' => 'field_cognome',
                'label' => 'Cognome',
                'name' => 'cognome',
                'type' => 'text',
                'required' => 1,
            ],
            [
                'key' => 'field_azienda',
                'label' => 'Azienda',
                'name' => 'azienda',
                'type' => 'text',
            ],
        ],
        'location' => [[[
            'param' => 'post_type',
            'operator' => '==',
            'value' => 'enrico',
        ]]],
    ]);
});

// 3. PARTE FINALE - Mostra i campi nel frontend sotto al contenuto
add_filter('the_content', function($content) {
    if (!is_singular('enrico') || !in_the_loop() || !is_main_query()) return $content;

    $nome = get_field('nome');
    $cognome = get_field('cognome');
    $azienda = get_field('azienda');

    $html = '<div class="dati-enrico" style="margin-top:20px; padding:15px; background:#f5f5f5;">';
    $html .= '<p><strong>Nome:</strong> ' . esc_html($nome) . '</p>';
    $html .= '<p><strong>Cognome:</strong> ' . esc_html($cognome) . '</p>';
    $html .= '<p><strong>Azienda:</strong> ' . esc_html($azienda) . '</p>';
    $html .= '</div>';

    return $content . $html;
});
 <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//agenziaweb21.com/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://agenziaweb21.com/post-sitemap1.xml</loc>
		<lastmod>2025-10-13T14:48:08+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://agenziaweb21.com/post-sitemap2.xml</loc>
		<lastmod>2024-05-30T13:00:54+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://agenziaweb21.com/post-sitemap3.xml</loc>
		<lastmod>2024-05-30T13:00:54+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://agenziaweb21.com/post-sitemap4.xml</loc>
		<lastmod>2024-05-30T13:00:53+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://agenziaweb21.com/post-sitemap5.xml</loc>
		<lastmod>2024-05-30T13:00:52+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://agenziaweb21.com/page-sitemap.xml</loc>
		<lastmod>2026-09-28T18:51:58+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Rank Math SEO Plugin (c) Rank Math - rankmath.com -->