Home Forums Plugin Support WP User Frontend Pro google map for category posts

This topic is: resolved

This topic contains 5 replies, has 3 voices, and was last updated by  Olivier 4 years, 8 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #26174

    Olivier
    Member
    Post count: 6

    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

    #26224

    Olivier
    Member
    Post count: 6

    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 ?

    #26250

    Sekander Badsha
    Member
    Post count: 2067

    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.

    #26255

    Olivier
    Member
    Post count: 6

    Hi,
    Thanks for the answer,
    unfortunatly it doesnt solve the issue,
    The thing is that by calling the map in the theme :
    < ?php echo wpuf_shortcode_map( 'location', $post->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

    #26294

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #26314

    Olivier
    Member
    Post count: 6

    Thanks,
    Manages doing it at the end,

    Olivier

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘google map for category posts’ is closed to new replies.