下面的代码适用于我的 single.php。php if ( have_posts() ) 调用标准的 wordpress 特征图像,而 function_exists('dfi_get_featured_images') 部分抓取包含在 nivo-slider 样式中的滑块图像。
php if ( have_posts() ) 循环正在破坏脚本。我试图将它包含在 if else 语句中,以便仅在帖子中没有幻灯片图像时才显示 wordpress 特色图像 if($featuredImages!=NULL)。
对编码的任何帮助都会很棒。
谢谢...李
<div id="featured" class="row-fluid">
<?php
if ( function_exists('dfi_get_featured_images') ) {
$featuredImages = dfi_get_featured_images();
if( !is_null($featuredImages) ){
echo "<div class='slider-wrapper theme-default'>";
echo "<div class='entry-thumbnail nivoSlider' style='width: 1170px;'>";
foreach($featuredImages as $images) {
echo "<a href='" . get_permalink() . "' title = '" . dfi_get_image_alt_by_id($images['attachment_id']) . "'>";
echo "<img src = '" . $images['thumb'] . "' />";
echo "</a>";
}
echo "</div>";
echo "</div>";
}
}
if($featuredImages!=NULL)
{
}
else
{
<?php if ( have_posts() ) { ?>
<?php while ( have_posts() ) { ?>
<?php the_post(); ?>
<?php if ( '' != get_the_post_thumbnail() ) { ?>
<?php the_post_thumbnail( 'full' ); ?>
<?php } // end if ?>
<?php } // end while ?>
<?php } // end have_posts ?>
}
?>