将相关帖子片段添加到我的本地网站,效果非常好。
上传到服务器 - 数字海洋 - 现在带来死亡白屏
<?php
<?php Starkers_Utilities::get_template_parts( array('parts/shared/html-header', 'parts/shared/header' ) ); ?>
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<div class="full-width blog-single-hero hero" style="background: url('<?php echo $backgroundImg[0]; ?>') no-repeat;background-size:cover;">
<?php Starkers_Utilities::get_template_parts( array( 'parts/shared/navigation' ) ); ?>
<div class="container animated fadeInDelay clear">
<div class="full">
<h1><?php the_title(); ?></h1>
</div><!--full-->
</div><!--container-->
</div><!--hero-->
<div class="container blog-index animated fadeInDelay clear">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<article class="single-blog-post <?php foreach((get_the_category()) as $category) {echo $category->cat_name . ' ';}?>">
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<div class="share-icons wow fadeIn" data-wow-delay="0.3s">
<h2>Please Share This Article!</h2>
<script type="text/javascript" src="//platform-api.sharethis.com/js/sharethis.js#property=593154b67442e0001200a27f&product=inline-share-buttons"></script>
<div class="sharethis-inline-share-buttons"></div>
</div><!--ends share-->
<div class="related-posts wow fadeIn" data-wow-delay="0.3s">
<h2>Other Posts You May Like!</h2>
<?php $orig_post = $post; global $post; $categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
$args=array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=> 3, // Number of related posts that will be shown.
'caller_get_posts'=>1
);
$my_query = new wp_query( $args );
if( $my_query->have_posts() ) {
echo '<div class="related-posts">';
while( $my_query->have_posts() ) {
$my_query->the_post();?>
<div class="four">
<a href="<? the_permalink()?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a>
<h2><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div><!--four-->
<? } echo '</div>';}}
$post = $orig_post;
wp_reset_query(); ?>
</div><!--ends related-posts-->
</article>
<?php endwhile; ?>
</div><!-- container -->
任何想法为什么?
这是wordpress的single.php文件
我在另一个使用wordpress但使用相同代码但在不同服务器上的网站上工作,这可能是原因吗?