Support » Plugin: Yandex Map for ACF » Как вывести метки для категории?

  • Карта выводится на странице архива, как сделать так, чтобы метки брались из текущей категории товаров? Чтоб в каждой категории на карте отображались только метки товаров из данной категории. Подскажите, пожалуйста.

    Вот такой код сейчас используется для вывода всех меток:

    function the_multiple_yandex_map($post_ids = array())
    {
        $marks = array(); // Все метки
        $marks_counter = 1;
    
        foreach ($post_ids as $post_id) {
            $data = (array)json_decode(get_field('halls_mapya', $post_id, false), true); // загрузка меток из записи
            if (!isset($data['marks']) || !is_array($data['marks'])) {
                continue;
            }
    
            foreach ((array)$data['marks'] as $mark) {
                $mark['id'] = $marks_counter;
    			$mark['content'].='<a href="'.get_permalink($post_id).'">'.get_the_title($post_id).'</a>';
    			$mark['content'].=get_the_post_thumbnail($post_id);
                $marks[] = $mark;
    
                $marks_counter++;
            }
        }
    
        $map_data = (array)json_decode(get_field('halls_mapya', get_the_ID(), false), true);
    	$map_data = array(
            "center_lat" => 55.755456,
            "center_lng" => 37.623104,
            "zoom" => 10,
            "type" => "map"
        );
        $map_data['marks'] = $marks;
    	
    
        the_yandex_map('', false, json_encode($map_data), 450);
    }
Viewing 1 replies (of 1 total)
  • Thread Starter kolhox

    (@kolhox)

    Похоже, что вот так:

    	if(is_product_category('61')) {
            $map_data = array(
            "center_lat" => 15.755456,
            "center_lng" => 37.623104,
            "zoom" => 10,
            "type" => "map"       
        );       
        }else{
            $map_data = array(
            "center_lat" => 55.755456,
            "center_lng" => 37.623104,
            "zoom" => 10,
            "type" => "map"     
        );
        
        }
        $map_data['marks'] = $marks;   
    • This reply was modified 5 years, 5 months ago by kolhox.
    • This reply was modified 5 years, 5 months ago by kolhox.
Viewing 1 replies (of 1 total)
  • The topic ‘Как вывести метки для категории?’ is closed to new replies.