true, 'orderby' => 'rand', 'order' => 'ASC', 'post_type' => 'marker', 'post_status' => 'any', 'author' => $author, 'tag' => $tag, 'post__not_in' => $not_post, 'tag__not_in' => $tag_not, //'tag__in' => array( 37, 47 ), ); $all_posts=new WP_Query($args); $tracklist = ""; $tracklist = "
    "; $objetos = array(); $links = ""; $span = array(); $total = count($all_posts->posts); //echo $total; echo '{ "type": "FeatureCollection", "crs": {"type": "name", "properties": { "name": "EPSG:3857" } }, "features": ['; foreach( $all_posts->posts as $post ) : setup_postdata($post); $tit = array(); $tit['titulo'] = $post->post_title; $tit['id'] = $post->ID; $tit['author']=get_post_meta($post->ID,'soundmap_marker_author',TRUE); $tags = wp_get_post_tags( $post->ID, array( 'fields' => 'names' ) ); $tags = implode(", ",$tags); $tit['category'] = get_the_category($post->ID); $c="no-category"; if (!empty($tit['category'])) { foreach ($tit['category'] as $cat): $c=$cat->name; endforeach;} //print_R($tit['category']); $image_id = get_post_thumbnail_id($tit['id']); $imagesize="single-post-thumbnail"; $tit['img'] = wp_get_attachment_image_src($image_id); $tit['img'] = basename($tit['img'][0]); $image_url = get_the_post_thumbnail($tit['id']); $m_lat = get_post_meta($post->ID,'soundmap_marker_lat', TRUE); $m_lng = get_post_meta($post->ID,'soundmap_marker_lng', TRUE); $tit['date']=get_post_meta($post->ID,'soundmap_marker_date', TRUE); $data = array(); $files = get_post_meta($post->ID, 'soundmap_attachments_id', FALSE); $data['m_files'] = array(); foreach ($files as $key => $value){ $file = array(); $att = get_post($value); $file['fileURI'] = wp_get_attachment_url($value); $tracklist .="
  • {$post->post_title}
  • "; $data['m_files'][] = $file; } $tit['archivos'] = $data['m_files']; $objetos[] = $tit; $order = array("\r\n", "\n", "\r"); $order2 = array("
    \r\n", "
    \r\n"); $content = json_encode(str_replace($order,'
    ',str_replace($order2,'',trim($post->post_content)))); //json_encode(trim(preg_replace('"', '',$content))) echo ' { "type": "Feature"'; if ($m_lng!="") : echo ', "geometry": {"type": "Point","coordinates": ['.$m_lng.', '.$m_lat.']}'; endif; echo ', "properties": { "id" : '.$tit['id'].', "date" : "'.$tit['date'].'", "category": "'.$c.'","title": '.json_encode($tit['titulo']).', "author" : "'.$tit['author'].'", "href" : "", "content" : '.$content.', "attachment" : "'.$file['fileURI'].'","image-url":"'.str_replace('"','\'',$image_url).'","image" : "'.str_replace('"','\'',$image_url).'" } },'; endforeach; echo '{"type":"Feature"}'; echo " ] }"; ?>