Не очищаются кастомные записи в базе
использую такой для создания записей и затем их вывода на карте.
$onepress_service_id = get_theme_mod( 'onepress_services_id', esc_html__('services', 'onepress') );
$onepress_service_disable = get_theme_mod( 'onepress_services_disable' ) == 1 ? true : false;
$onepress_service_title = get_theme_mod( 'onepress_services_title', esc_html__('Our Services', 'onepress' ));
$onepress_service_subtitle = get_theme_mod( 'onepress_services_subtitle', esc_html__('Section subtitle', 'onepress' ));
// Get data
$page_ids = onepress_get_section_services_data();
if ( onepress_is_selective_refresh() ) {
$onepress_service_disable = false;
}
if ( ! empty( $page_ids ) ) {
$layout = intval( get_theme_mod( 'onepress_service_layout', 6 ) );
$desc = get_theme_mod( 'onepress_services_desc' );
?>
<?php if (!$onepress_service_disable) : ?>
<?php if ( ! onepress_is_selective_refresh() ){ ?>
<section id="<?php if ($onepress_service_id != '') echo $onepress_service_id; ?>" <?php do_action('onepress_section_atts', 'services'); ?> class="<?php echo esc_attr(apply_filters('onepress_section_class', 'section-services section-padding section-meta onepage-section', 'services')); ?>"><?php } ?>
<?php do_action('onepress_section_before_inner', 'services'); ?>
<?php if ( $onepress_service_title || $onepress_service_subtitle || $desc ){ ?>
<div class="section-title-area">
<?php if ($onepress_service_subtitle != '') echo '<h5 class="section-subtitle">' . esc_html($onepress_service_subtitle) . '</h5>'; ?>
<?php if ($onepress_service_title != '') echo '<h2 class="section-title">' . esc_html($onepress_service_title) . '</h2>'; ?>
<?php if ( $desc ) {
echo '<div class="section-desc">' . apply_filters( 'onepress_the_content', wp_kses_post( $desc ) ) . '</div>';
} ?>
</div>
<?php } ?>
<div id="map_wrap">
<div id="map"></div>
<div id="menu_wrap"></div>
</div>
<script>
var items=[];
<?php
if ( ! empty( $page_ids ) ) {
global $post;
$j = 0;
foreach ($page_ids as $settings) {
$post_id = $settings['content_page'];
$post_id = apply_filters( 'wpml_object_id', $post_id, 'page', true );
//echo $post_id."####";
$post = get_post($post_id);
$info = get_post_meta($post_id, "info",true);
$coords = $info['coords'];
setup_postdata($post);
$settings['icon'] = trim($settings['icon']);
?>
var item=
{
center: [<?php echo $coords;?>], // Координаты точки
name: "<?php the_title(); ?>", // Имя
hintContent: '<?php the_title(); ?>', // Подсказка при наведении
content: {
balloonContentHeader:
'<div class="title-info">' +
' <div class="name"><a href="<?php the_permalink(); ?>"><?php echo $info['title'];?></a></div>' +
'</div>',
balloonContentBody:
'<div class="object-info">' +
' <div class="object">' +
' <div class="object-addr"><?php echo $info['address'];?></div>' +
' <div class="object-phone"><?php echo $info['telephone'];?></div>' +
' <div class="object-mail"><?php echo $info['email'];?></div>' +
' </div>' +
' <div class="user-name"><?php echo $info['contact_item'];?></div>' +
'</div>',
balloonContentFooter: ''
}
};
items.push(item);
<?php
}
wp_reset_postdata();
}
?>
В консоли возникают ошибки Illegal string offset 'coords'; Illegal string offset 'title'; Illegal string offset 'address' и т.д.
У меня было 10 записей, 3 я удалили, и эти ошибки появляются трижды, удалил 4 пост, ошибки появляются четырежды. Не пойми как сделать refresh