bigdave bigdave - 1 year ago 87
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;
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=>3, // Number of related posts to display.

$my_query = new wp_query( $args );

while( $my_query->have_posts() ) {
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');?>
<h5 class="reltitle"><?php the_title(); ?></h5>
<p><?php the_excerpt(); ?></p>

<? }
$post = $orig_post;


Can anyone see something that I'm missing?

Answer Source

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;

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download