无法拉入特色图片

时间:2013-09-04 21:23:24

标签: php wordpress wordpress-theming

我使用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(); ?>

谢谢!

1 个答案:

答案 0 :(得分: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