WordPress.org

Ready to get started?Download WordPress

Forums

Pronamic Google Maps
[resolved] Adapt results to query_post() (5 posts)

  1. Mark Jansen
    Member
    Posted 1 year ago #

    I am using this plugin on an archive page for projects. I have 2 possible views, a list view and a mapview.

    In settings, the number of blogposts is set at 5, but whatever I try, I can't seem to override that number for the map.

    I want to display all the projects on the map, where I want a paginated list, in the list view.

    Both
    global $query_string; query_posts($query_string.'&post_type=project&posts_per_page=10');

    and

    if(function_exists('pronamic_google_maps_mashup')) {
                pronamic_google_maps_mashup(
                    array(
                        'post_type' => 'project',
                        'numberposts' => 10,
                    ) ,
                    array(
                        'width' => 480 ,
                        'height' => 480 ,
                        'map_type_id' => 'roadmap'
    
                    )
                );
            }

    appear to be non-working solutions.

    Anyone that can offer me a kick in the right direction?

    http://wordpress.org/extend/plugins/pronamic-google-maps/

  2. Remco Tolsma
    Member
    Plugin Author

    Posted 1 year ago #

    bq. I want to display all the projects on the map,

    The following should work:

    if ( function_exists( 'pronamic_google_maps_mashup' ) ) {
    	pronamic_google_maps_mashup(
    		array(
    			'post_type' => 'project' ,
    			'posts_per_page' => -1 ,
    		) ,
    		array(
    			'width' => 480 ,
    			'height' => 480 ,
    			'map_type_id' => 'roadmap'
    		)
    	);
    }

    I use 'posts_per_page' instead of the 'numberposts' parameter:
    http://codex.wordpress.org/Function_Reference/WP_Query#Pagination_Parameters

    You could ofcourse also use the 'nopaging' => false parameter.

  3. Mark Jansen
    Member
    Posted 1 year ago #

    This indeed seems to work. Thanks Remco

  4. __jester
    Member
    Posted 1 year ago #

    By the way Mark,...you should never use 'query_posts', use 'WP_Query' (for subloops) or the 'pre_get_posts'-hook (to alter the main loop) instead.

  5. Mark Jansen
    Member
    Posted 1 year ago #

    Yeah, I know. I was building on to something that already existed, but I should change that, I know.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic