google map for category posts

This topic contains 5 reply and 3 voices, and was last updated by Olivier 9 years, 7 months ago
Viewing 5 Posts - 1 through 5 (of 5 total)
Author Posts
September 2, 2014 at 3:28 pm 26174
Olivier Hi, I have a website where user can refers locations, so each post refers a special location, How can I call a map in my category-ID.php for all the locations from a special category (showing all the post markers from the category)? (each category have his own specific form, so it need to call only the ones from one category) Thanks a lot, Olivier
September 3, 2014 at 2:43 pm 26224
Olivier Olivier

As a test, I’ve tried in this direction but without success for exemple to retrieve all the locations from posts within category 2 … :


<?php 
$post_ids = get_posts(array(
    'numberposts'   => -1, 
    'tax_query'     => array(
        array(
            'taxonomy'  => 'category',
            'field'     => 'id',
            'terms'     => 2,
        ),
    ),
    'fields'        => 'ids', 
));

echo wpuf_shortcode_map( 'location', $post_ids ); ?>

Do someone has an idea how I can achieve that ?

September 3, 2014 at 6:38 pm 26250
Sekander Badsha Sekander Badsha

Hello Olivier,
We’re saving the Google Map Coordinates in post_meta. So you can get the data from calling the post_meta. I the thing you’re trying to do is I guess would be quite tough.
You may include a dropdown or something to choose their location. In this way that would be easier to filter.

September 3, 2014 at 7:13 pm 26255
Olivier Olivier

Hi,
Thanks for the answer,
unfortunatly it doesnt solve the issue,
The thing is that by calling the map in the theme :
ID ); ?>
It loaded the special ID from the post ($post->ID), what I would like is that it can load an array of ID instead of just one, do you think it is possible ?
In case not, how can I extract the latitude and longitude as numbers written in php ?
Thanks in advance,
Olivier

September 4, 2014 at 1:40 pm 26294
Tareq Hasan Tareq Hasan

The way you wrote the code, you have to loop through the $post_ids and fetch the individual post meta for the co-ordinates and store them in a array. Then you’ve to display those co-ordinates in a map. wpuf_shortcode_map function won’t show all those locations in the map, you’ve to write custom.

September 4, 2014 at 7:16 pm 26314
Olivier Olivier

Thanks,
Manages doing it at the end,

Olivier

Viewing 5 Posts - 1 through 5 (of 5 total)