分类学图像div背景

时间:2016-12-28 22:21:48

标签: php wordpress

我想在div风格背景(xxxxx)中设置分类图像url。我使用“taxonomy images”插件,但wp_get_attachment_image不起作用。

<?php
$terms = apply_filters( 'taxonomy-images-get-terms', '', array(
        'taxonomy'     => 'categoria_proyectos',
    ));

if ( ! empty( $terms ) ) {
    print '';
    foreach ( (array) $terms as $term ) {
        print '
        <a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '">
        <div class="style="background-image: url(xxxxxx); ">
        </div>
        </a>';
    }
}
?>

1 个答案:

答案 0 :(得分:0)

您可以尝试使用此代码获取附加的精选图片的网址。

<?php echo wp_get_attachment_image( get_the_ID(), array('700', '600'), "", array( "class" => "img-responsive" ) ); ?>