• Resolved bhenselmann

    (@bhenselmann)


    Hello,
    could anybody give me a hint, how to select posts (from a costum post type – but maybe this is not relevant?) by using custom fields (meta_key / meta_value) to show an a global map?
    I found something in the documentation, that it is possible to use a WP_Query object in map_content.
    How to do this?
    Thanks a lot!
    Bernhard

    https://wordpress.org/plugins/geo-mashup/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Dylan Kuhn

    (@cyberhobo)

    You must use the template tag to do this:

    <?php
    $custom_query = new WP_Query( array(
    	'post_type' => 'thing',
    	'posts_per_page' => -1,
    	'meta_key' => 'color',
    	'meta_value' => 'blue',
    ) );
    
    echo GeoMashup::map( array(
    	'map_content' => $custom_query,
    ) );
    ?>

    Thread Starter bhenselmann

    (@bhenselmann)

    Hi Dylan,
    thanks for that fastest response. I´ll try the code!

    Thread Starter bhenselmann

    (@bhenselmann)

    Hi Dylan,
    I’ve tried the code but unfortunately it is not working.

    I´ve tried the code

    <?php
    $custom_query = new WP_Query( array(
    ‘post_type’ => ‘kommune’,
    ‘posts_per_page’ => -1,
    ‘meta_key’ => ‘Friedhofsatzung’,
    ‘meta_value’ => ‘Friedhofsatzungsbeschluss’,
    ) );

    echo GeoMashup::map( array(
    ‘map_content’ => $custom_query,
    ‘width’ => 500,
    ‘height’ => 600,
    ‘zoom’ => 6,
    ‘center_lat’ => 51.2,
    ‘center_lng’ => 10,
    ‘map_type’ => ‘G_HYBRID_MAP’,
    ‘cluster_max_zoom’ => 0,
    ‘add_overview_control’ => ‘false’,
    ‘add_map_type_control’ => ‘false’,
    ‘interactive_legend’ => ‘false’,
    ‘name’ => ‘friedhofsatzungen’
    ) );
    ?>

    in the theme template and directly in the page.

    The
    ‘map_content’ => $custom_query,
    in the echo block seems to produce an problem – the page is not loading completely.
    I´ve also tried to put the map_post_type attribute to the shortcode – this is not working, too.

    Do you have an idea, what I´m doing wrong?

    Thanks
    bernhard

    Plugin Author Dylan Kuhn

    (@cyberhobo)

    Looks okay to me. The code must go in the page template. There may be more clues in your PHP error logs if there is a syntax problem there.

    Thread Starter bhenselmann

    (@bhenselmann)

    Thanks a lot Dylan! It works! I´ve tried first in a test environment with an older version of the plugin. Sorry!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘costum fields to select posts for map’ is closed to new replies.