bigdave bigdave - 29 days ago 15
PHP Question

WP "related posts" php causing white screen

I have a sinlge post template which works just fine on my dev server but when pushing live pages using this template return a white screen. I've narrowed it down to the 'related posts' section of the template but I cant see what it is thats causing the issue or why it's only causing the issue on live and not dev..

<div class="related max980 clearfix">
<h1 class="max980 marbot-20">Related Posts</h1>
<?php $orig_post = $post; global $post; $tags = wp_get_post_tags($post->ID);

if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=>3, // Number of related posts to display.
'caller_get_posts'=>1
);

$my_query = new wp_query( $args );

while( $my_query->have_posts() ) {
$my_query->the_post();
add_image_size( 'related-thumb-size', 420, 220, array( 'top', 'center' ));
?>


<div class="col-xs-4 clearfix">
<a rel="external" href="<? the_permalink();?>">
<div class="relatedthumb">
<?php the_post_thumbnail('related-thumb-size');?>
</div>
<h5 class="reltitle"><?php the_title(); ?></h5>
<p><?php the_excerpt(); ?></p>
</a>
</div>


<? }
}
$post = $orig_post;
wp_reset_query();
?>

</div>


Can anyone see something that I'm missing?

Answer

The white screen appears due to syntax issues. You should look into the error log.

I see a syntax error in below block at first line.

<? }
}
$post = $orig_post;
wp_reset_query();
?>

On the first line of this code you are missing PHP opening tag.