改变阵列显示the_title WordPress的

问题描述:

我现在有改变阵列显示the_title WordPress的

<?php 
    $attr = array(
     'title' => 'here is a title', 
     'alt' => 'here is a alt attribute' 
    ); 
?> 
    div class="s-o-column"> 
     <div class="s-o-thumb"><a href="<?php echo $termlink; ?>"><?php echo wp_get_attachment_image($term->image_id, 'standard-options-thumb', false, $attr ); ?></a> 
     <div class="s-o-title"><a href="<?php echo $termlink; ?>"><?php echo $term->name; ?></a></div> 
    </div> 
</div> 

我如何改变它,标题和alt的说; <?php the_title(); ?>而不是“这是一个标题”或“这是一个ALT属性”?

+0

你能对你的问题更加清楚一点..我还没有得到它.. – 2013-04-09 04:40:28

+0

好了,numbnails现在的标题,并在阵列中提供ALTS显示,我想,但数组检测帖子标题或缩略图的标题并替换。 – Eddie 2013-04-09 04:41:43

您应该使用get_the_title()而不是the_title(),因为get_the_title()返回标题,而the_title()会回应它。

$attr = array(
    'title' => get_the_title(), 
    'alt' => 'here is a alt attribute' 
);