// 3. АВТОМАТИЧЕСКИЙ ВЫВОД ХАРАКТЕРИСТИК (ACF) НА СТРАНИЦЕ ОБЪЕКТА
function svoydom_display_acf_fields_in_content($content) {
    // Проверяем, что мы на странице Квартиры, Дома или Участка
    if ( is_singular( array('apartments', 'land_plots', 'houses') ) && function_exists('get_field_objects') ) {
        
        // Создаем красивый блок с серым фоном
        $custom_html = '<div class="property-characteristics" style="background: #f8f9fa; padding: 25px; border-radius: 12px; margin-top: 30px; border: 1px solid #eaeaea;">';
        $custom_html .= '<h3 style="margin-top:0; font-size: 22px; color: #333;">Характеристики объекта:</h3>';
        $custom_html .= '<ul style="list-style: none; padding-left: 0; margin-bottom: 0;">';

        // Получаем все поля, которые ты заполнила для этого объекта
        $fields = get_field_objects();

        if ( $fields ) {
            foreach ( $fields as $field_name => $field ) {
                // Прячем кадастровый номер от обычных посетителей (оставляем для админа)
                if ( $field_name === 'cadastre_number' ) continue;

                // Проверяем, заполнено ли поле
                if ( $field['value'] ) {
                    $value = $field['value'];

                    // Если это несколько галочек (например, коммуникации), объединяем их через запятую
                    if ( is_array($value) ) {
                        $value = implode(', ', $value);
                    }

                    // Красиво форматируем цену (добавляем пробелы и знак рубля)
                    if ( $field_name === 'price' ) {
                        $value = number_format((float)$value, 0, '', ' ') . ' ₽';
                    }
                    
                    // Выводим строку с характеристикой
                    $custom_html .= '<li style="margin-bottom: 12px; border-bottom: 1px dashed #ccc; padding-bottom: 8px; display: flex; justify-content: space-between;">';
                    $custom_html .= '<span style="color: #666;">' . esc_html($field['label']) . ':</span> ';
                    $custom_html .= '<strong style="color: #111;">' . esc_html($value) . '</strong>';
                    $custom_html .= '</li>';
                }
            }
        } else {
            $custom_html .= '<li>Характеристики пока не заполнены.</li>';
        }

        $custom_html .= '</ul></div>';
        
        // Приклеиваем этот блок в самый низ страницы, под основное описание
        $content = $content . $custom_html;
    }
    
    return $content;
}
add_filter('the_content', 'svoydom_display_acf_fields_in_content');<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://svoydom35.ru/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://svoydom35.ru/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://svoydom35.ru/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://svoydom35.ru/wp-sitemap-posts-apartments-1.xml</loc></sitemap><sitemap><loc>https://svoydom35.ru/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://svoydom35.ru/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
