I have WP Query like this:
$map_args = array(
'post_type' => 'spots',
'post_status' => 'publish',
'posts_per_page' => -1
);
$markers_query = new WP_Query($map_args); ?>
<?php if ($markers_query->have_posts()) : ?>
<?php while ($markers_query->have_posts()) : $markers_query->the_post();
$terms = get_the_terms( $post->ID , 'spots_categories' );
$map_marker = get_field( 'map_marker', $terms[0]->taxonomy . '_' . $terms[0]->term_id );
$tooltip_photo = get_the_post_thumbnail($post->ID, 'thumbnail', array('class' => 'marker-pop__photo'));
$marker_url = esc_url(get_the_permalink());
if ( $spot_location = get_field( 'spot_location' ) ) :
$markersArray[] = array($spot_location['lat'], $spot_location['lng'], get_the_title(), 'http://localhost/icamp/app/wp-content/themes/iCamp/images/logo-black.svg', $tooltip_photo, $marker_url );
endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
<?php wp_reset_postdata(); ?>
'spots' is my custom post type, and 'spots_categories' is my custom taxonomy. I have over 10.000 CPT in spots right now, so that query is really slow. I need all my posts (can't use pagination here), because I need to list that locations on leaflet map (pins with title, thumbnail and custom marker). Is there any better and faster way to list my custom pins with location to leaflet map? That Query is really slow.
if
beforewhile
is useless, right? \$\endgroup\$