Reply To: using the_content and the_tags witin map_poi_list.php

Home Forums MapPress Support using the_content and the_tags witin map_poi_list.php Reply To: using the_content and the_tags witin map_poi_list.php

#14668
Chris
Keymaster

Hi,

Are you using a map or a mashup?

WordPress has two types of functions: those that take a post ID and those that work on the global $post from The Loop. Usually the latter kind have ‘the_’ in the function name. A few functions can work either way (the post ID is optional).

For mashups, the POI list is generated using AJAX. During AJAX calls there is no The Loop, so functions based on the global $post won’t work.

For your situation it’s probably easiest to just use the functions that take a post ID:

<?php
	$postid = ($poi->postid) ? $poi->postid : $post->ID;
	$post_ = get_post($postid);
?>
<?php if ($post_) :?>
<div>
   <span><?php echo get_the_tag_list('', ', ', '', $post_->ID); ?></span>
   <?php echo apply_filters('the_content', $post_->post_content); ?>
</div>
<?php endif; ?>

If you must use the global $post functions, then you need to set up the global data before calling the function. For example:

<?php
	global $post;
	if ($poi->postid && $post_ = get_post($poi->postid)) {
		$post = $post_;
		setup_postdata($post);
	}
?>
<?php if ($post_) : ?>
<div><?php the_tags();?></div>
<div><?php the_content();?></div>
<?php endif; ?>