Support » Plugin: Advanced Classifieds & Directory Pro » Display more than 5 markers on the map-view?

  • Resolved j09

    (@j09)


    Hello again!

    There is a setting in the settings page that controls how many listings get displayed in each page. When you set this to a number, for example 5 or 6, it also applies to the map-view of the listings.

    This results in only 5 listings displayed on the map-view (only 5 markers)

    I think this is a very similar problem to this one here:
    display more than 5 custom fields on each listing on the listings page

    And the fix in that case was to define a number of displayed items independently of the general settings by adding 'posts_per_page' => -1 to the loop for custom fields.

    I have attached the loop for the map-view of the listings below. How do you display more than 5 listings (markers) on the map view while keeping the setting set to 5?

    What I am trying to achieve is 5 listings per page on grid-view and show all listings at once on the map-view.

    I hope that’s clear enough.

    <!-- the loop -->
        <div class="acadp-map embed-responsive embed-responsive-16by9 acadp-margin-bottom" data-type="markerclusterer"> 
    		<?php while( $acadp_query->have_posts() ) : $acadp_query->the_post(); $post_meta = get_post_meta( $post->ID ); ?>
        
        		<?php if( ! empty( $post_meta['latitude'][0] ) && ! empty( $post_meta['longitude'][0] ) ) : ?>
            		<div class="marker" data-latitude="<?php echo $post_meta['latitude'][0]; ?>" data-longitude="<?php echo $post_meta['longitude'][0]; ?>">
                		<div <?php the_acadp_listing_entry_class( $post_meta, 'media' ); ?>>
                    		<?php if( $can_show_images ) : ?>
                            	<div class="media-left">
                    				<a href="<?php the_permalink(); ?>"><?php the_acadp_listing_thumbnail( $post_meta ); ?></a> 
                                </div>     	
                			<?php endif; ?>
                
                			<div class="media-body">
                        		<div class="acadp-listings-title-block">
                        			<h3 class="acadp-no-margin"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                	<?php the_acadp_listing_labels( $post_meta ); ?>
                            	</div>
                            
                            	<?php
    								$info = array();					
    		
    								if( $can_show_date ) {
    									$info[] = sprintf( __( 'Posted %s ago', 'advanced-classifieds-and-directory-pro' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) );
    								}
    							
    								if( $can_show_user ) {			
    									$info[] = '<a href="'.acadp_get_user_page_link( $post->post_author ).'">'.get_the_author().'</a>';
    								}
    
    								echo '<p class="acadp-no-margin"><small class="text-muted">'.implode( ' '.__( "by", 'advanced-classifieds-and-directory-pro' ).' ', $info ).'</small></p>';
    							?>
                            
                            	<p class="acadp-listings-desc"><?php echo wp_trim_words( get_the_content(), $listings_settings['excerpt_length'], '...' ); ?></p>
                            
                            	<?php
    								$info = array();					
    		
    								if( $can_show_category && $category = wp_get_object_terms( $post->ID, 'acadp_categories' ) ) {
    									$info[] = '<span class="fa fa-flag"></span>&nbsp;&nbsp;<a href="'.acadp_get_category_page_link( $category[0] ).'">'.$category[0]->name.'</a>&nbsp;';
    								}
    					
    								if( $can_show_location && $location = wp_get_object_terms( $post->ID, 'acadp_locations' ) ) {
    									$info[] = '&nbsp;<span class="fa fa-map-marker"></span>&nbsp;&nbsp;<a href="'.acadp_get_location_page_link( $location[0] ).'">'.$location[0]->name.'</a>&nbsp;';
    								}
    							
    								if( 'acadp_favourite_listings' == $shortcode ) {
    									$info[] = '<a href="'.acadp_get_remove_favourites_page_link( $post->ID ).'">'.__( 'Remove from favourites', 'advanced-classifieds-and-directory-pro' ).'</a>';
    								}
    					
    								if( $can_show_views && ! empty( $post_meta['views'][0] ) ) {
    									$info[] = sprintf( __( "&nbsp;<span class='fa fa-eye'></span>&nbsp;%d views", 'advanced-classifieds-and-directory-pro' ), $post_meta['views'][0] );
    								}
    
    								echo '<p class="acadp-no-margin"><small>'.implode( ' | ', $info ).'</small></p>';
    	
                    				if( $can_show_price && isset( $post_meta['price'] ) && $post_meta['price'][0] > 0 ) {
    									$price = acadp_format_amount( $post_meta['price'][0] );						
    									echo '<p class="lead acadp-listings-price">'.acadp_currency_filter( $price ).'</p>';
    								}            		
                    			?>
                        	</div>
                    	</div>
                	</div>
            	<?php endif; ?> 
                   
      		<?php endwhile; ?>
        </div>
        <!-- end of the loop -->

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author pluginsware

    (@pluginsware)

    1. Open the following files,

    – /public/class-acadp-public-listings.php
    – /public/class-acadp-public-locations.php
    – /public/class-acadp-public-categories.php
    – /public/class-acadp-public-search.php

    2. Search for the following line,
    'posts_per_page' => (int) $atts['listings_per_page'],

    3. Replace it as,
    'posts_per_page' => ('map' == $view) ? -1 : (int) $atts['listings_per_page'],

    4. Save the changes and try now.

    Thread Starter j09

    (@j09)

    That worked flawlessly!

    Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display more than 5 markers on the map-view?’ is closed to new replies.