Forum Moderators: coopster

Message Too Old, No Replies

Please help with this script

         

gearupandplay

9:58 pm on Mar 21, 2010 (gmt 0)

10+ Year Member



I don't know much about coding but looking at examples I think I need to break this script up to insert a piece of php code that I need inserted. The code I'm trying to insert is this
<?php echo GeoMashup::map('width=695&height=400') ?>
Looking at examples I think I need to insert it inbetween the (if) have post statement and the (while) have post statement. Something like this
<?php if (have_posts()) : ?>
<?php echo GeoMashup::map('width=695&height=400') ?>
<?php while (have_posts()) : the_post(); ?>


My problem is I can't seem to break up this big chunk into something that works. I get a error on the page. Can anyone help me. I don't know much about php. Thanks
<?php //for use in the loop, list 5 post titles related to first tag on current post
$backup = $post; // backup the current object
$tags = wp_get_post_tags($post->ID);
$tagIDs = array();
if ($tags) {
$tagcount = count($tags);
for ($i = 0; $i < $tagcount; $i++) {
$tagIDs[$i] = $tags[$i]->term_id;
}
$args=array(
'tag__in' => $tagIDs,
'post__not_in' => array($post->ID),
'showposts'=>5,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
<?php endwhile;
} else { ?>
<h2>No related posts found!</h2>
<?php }
}
$post = $backup; // copy it back
wp_reset_query(); // to use the original query again
?>

adams

6:28 pm on Mar 24, 2010 (gmt 0)

10+ Year Member



What's your error?

Can I also suggest you don't close and open PHP tags? It's bad practice. Instead, echo it, or add it to a variable