0

我使用 wordpress 主题作为基础来提供水平视差滚动。我的一切工作都很好,但是当我尝试将特色图片拉到页面中时(请参阅内容),什么都不会拉起。我可以显示静态图像,但不能显示任何数量的标签甚至自定义字段。这是页面的代码:

<?php
/**
 * The main file.

 */
get_header(); ?>
<?php require( dirname( __FILE__ ) . "/inc/theme-options-vars.php" ); ?>


<!-- ==================== PARALLAX FUNCTIONS ==================== -->   
<?php for( $i=1; $i<=($numposts); $i++ )
{
echo '<div class="hw" id="page-'.$i.'">';
} ?>
<!-- ==================== PARALLAX FUNCTIONS ==================== -->   


<?php if($convax_bg1!==''){
echo'
<div class="elem-1">
<div class="elem-1-bg"></div>
</div>';
}
if($convax_bg2!==''){
echo'
<div class="elem-2">
<div class="elem-2-bg"></div>
</div>';
}
?>


<div class="hw" id="content-inner">


<?php 
$pages = get_pages( 'sort_order=asc&sort_column=menu_order&depth=1' );
foreach ( $pages as $pag ) {
setup_postdata( $pag );
$new_title = str_replace( " ", "", strtolower( $pag->post_title ) );
$tempname = get_post_meta( $pag->ID, '_wp_page_template', true );
$filename = preg_replace('"\.php$"', '', $tempname);
echo '<div class="page '.$new_title;
echo '" id="' . $new_title . '"><div class="page-info">';
if ( $new_title !== 'home' ) {
echo '<h1>';
echo  $pag->post_title;
$pag->post_title;
echo '</h1>';
}
?>



<!-- If Portfolio Page -->          
<?php if($filename == 'page-portfolio'):?>
<?php query_posts( array( 'post_type' => 'portfolio_item', 'orderby' => 'date', 'order' => 'ASC' ) ); ?>
<?php if(have_posts()): ?>
<div class="scrollbar1">
<div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div>            
</div></div></div>
<div class="viewport">
<div class="overview">
<div class="rec-proj">
<ul>
<?php while ( have_posts() ) : the_post(); ?>
<li>
<a href="#port-<?php echo $post->ID ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'convaxsolutions' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark" class="various">
<?php 
if(has_post_thumbnail()) {
the_post_thumbnail('thumbnail');
} else {
echo '<img src="'.get_bloginfo("template_url").'/images/default-featured-image.png" class="portfolio-thumb" width="60" height="60"/>';
}
?>
</a>
<?php edit_post_link('Edit'); ?>
</li>
<?php endwhile; ?>
</ul>
</div><!-- / rec proj -->
</div><!-- / .overview -->
</div><!-- / .viewport -->
</div><!-- / .Scrollbar1 --> 
<?php else: ?>
<h1 class="alert"></h1>
<?php endif; ?>



<?php else: ?>
<div class="scrollbar1">
<div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div>    </div></div></div>
<div class="viewport">


<!-- ==================== CONTENT ==================== -->  
<div class="overview">

    <?php the_content(); ?>

    <?php the_post_thumbnail('full'); ?>

</div>
<!-- ==================== CONTENT ==================== -->  


</div><!-- / .viewport -->
</div><!-- / .Scrollbar1 -->          

<?php endif; ?>
<!-- End If Portfolio-->            

<?php echo '</div></div>';
}
?>
<!-- End foreach -->            

</div>
<!-- / #content-inner -->

<?php for( $i=1; $i<=($numposts); $i++ )
{
echo '</div>';
} ?>


<?php get_footer(); ?>

谢谢!

4

1 回答 1

2

请看文档!获取图像:

get_the_post_thumbnail($pag->ID, 'full');

the_post_thumbnail($size, $attr); 的文档

该标签必须在 The Loop 中使用。使用 get_the_post_thumbnail($id, $size, $attr) 来获取任何帖子的特色图片。

http://codex.wordpress.org/Function_Reference/the_post_thumbnail

于 2013-09-04T22:12:09.197 回答