0

我目前有

    <?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 属性”?

4

1 回答 1

1

您应该使用get_the_title()而不是the_title()因为get_the_title()在回显标题时返回标题the_title()

$attr = array(
    'title' => get_the_title(),
    'alt' => 'here is a alt attribute'
);
于 2013-04-09T05:07:17.913 回答