Display user posts on map (solution 1 more request for user's favorites)
-
Hi everybody
Awesome plugin many thanks to author!Athough not sure this is relevant or might be of any interest for someone, here is how I display all posts from a user on a map on their profile (as you will see, i’m a beginner):
<?php global $current_user; get_currentuserinfo(); $args = array( 'author' => $current_user->ID, 'showposts' => '-1', 'post_status' => 'publish' ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); ?> <div style="display:none;"><?php echo '' . get_the_ID() . ','; ?></div> <?php } echo GeoMashup::map( array( 'map_content' => $the_query ) ); } ?> <?php wp_reset_postdata(); ?>
Works well.
(Is it ugly ?)***
Anyway, being unfamiliar with wp i’m having trouble when i want to display current user’s favorite posts on a map (using Wp Favorite Posts plugin), ie the posts that an user saved as his/her favorites.
I managed to get the good list of IDs separated by comas, just like above code. But it is with a “foreach” thing and i don’t know how to use it in my geomashup parameters.
Tried everything (queries, printf, …), nothing worked. This is the basis :
<?php $options = wpfp_get_options(); $favorite_post_ids = wpfp_get_users_favorites(); foreach ($favorite_post_ids as $post_id) { $p = get_post($post_id); echo " " . $p->ID . ", "; } //ok it actually displays a list of current user's favorite post separated by commas but how do i insert result inside this: echo GeoMashup::map( array( 'map_content' => //here the result?! ) ); ?>
Is this possible to “transform” this foreach thing into a regular query, just like in my first code? Or just use the output directly..?
Maybe this is very simple for someone… i feel rubish.Will update if solution is found. Sorry if not useful nor the right place to post. and definately for beeing so long.
Any help appreciated!
Cheers
- The topic ‘Display user posts on map (solution 1 more request for user's favorites)’ is closed to new replies.