• Resolved Nita

    (@nitayang)


    Hello, I was wondering if you could pull multiple post from one category instead of pulling from all the categories that has Google Maps active?

    For example, I have two categories, but I only want to display one category on the mashup map. Is there a php code that I can add into my php file?

    Below is the php code for the pronamic google map mash that I have. I want to add a code to pull just from one category. I would appreciate it very much if anyone can help me. Thank you.

    // THE ICON MARKER
    function prefix_pronamic_google_maps_marker_options_icon( $url ) {
    	if ( has_category( 'map1' ) ) {
    		return 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png';
    	}  else {
    		return $url;
    	}
    }
    
    add_filter( 'pronamic_google_maps_marker_options_icon', 'prefix_pronamic_google_maps_marker_options_icon' );
    
    /**
     * Template snippet
     */
    if ( function_exists( 'pronamic_google_maps_mashup' ) ) {
    	pronamic_google_maps_mashup(
    		array(
    			'post_type'      => 'post',
    			'nopaging'       => true
    		), array(
    			'width'          => 595,
    			'height'         => 500,
    			'map_type_id'    => 'roadmap',
    			'marker_options' => array(
    				'icon' => 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png'
    			)
    		)
    	);
    }
    
    ?>

    http://ww.wp.xz.cn/extend/plugins/pronamic-google-maps/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Nita

    (@nitayang)

    /**
     * Template snippet
     */
    if ( function_exists( 'pronamic_google_maps_mashup' ) ) {
    	pronamic_google_maps_mashup(
    		array(
    			'post_type'      => 'post',
    			'nopaging'       => true,
    			'category_name' => 'map1'
    		), array(
    			'width'          => 595,
    			'height'         => 500,
    			'map_type_id'    => 'roadmap',
    			'marker_options' => array(
    				'icon' => 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png'
    			)
    		)
    	);
    }
    
    ?>

    Hi, yes I solved it with ‘category_name’ => ‘the slug of the category

    Question??

    if I want to show a map on a category listing page with the markers of all posts that belong to that category, I insert in the category.php file this code,

    <?php

    if ( function_exists( ‘pronamic_google_maps_mashup’ ) ) {
    pronamic_google_maps_mashup(

    array(
    ‘category_name’ => ‘CURRENT CATEGORY SLUG
    ),

    array(
    ‘width’ => 600,
    ‘height’ => 400,

    )
    );
    }

    ?>

    This gives me the current category slug,

    <?php
    $category = get_the_category();
    echo $category[0]->slug;
    ?>

    but it doesn´t work if I place that code in the CURRENTCATEGORY SLUG field.

    Help please!!
    Thank you.

    Plugin Author Remco Tolsma

    (@remcotolsma)

    You could try to use the global WordPress query.

    if ( function_exists( 'pronamic_google_maps_mashup' ) ) {
    	global $wp_query;
    
    	$mashup_query = array_merge( $wp_query->query, array( 'nopaging' => true ) );
    
    	pronamic_google_maps_mashup(
    		$mashup_query,
    		array(
    			'width' => 600,
    			'height' => 400,
    		)
    	);
    }

    It works PERFECTLY!!
    Thanks a lot for your help Remco Tolsma!!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Pulling from 1 category post’ is closed to new replies.