Support Forum ยป User Profile

Forum Replies Created

Viewing 2 posts - 16 through 17 (of 17 total)
  • Author
    Posts
  • in reply to: Featured image in a category #34089
    victoria de clascavictoria de clasca
    Participant

    I am working on the archive Category template,

    sorry I didint say that

    in reply to: Featured image in a category #34088
    victoria de clascavictoria de clasca
    Participant

    I've looked at the documentation, and I found this code

    It only works in some categories, is there something wrong?

    I'm not sure if the code of categories is 'categories', how do I know?

    <?php
    $terms= get_the_terms( $post->ID, 'category');
    $background_image = get_term_meta( $terms[0]->term_id, 'single_image_taxonomy', true );
    if ($background_image) {
    $link_image = wp_get_attachment_image_src( $background_image, 'full' );
    $link_image_source = $link_image[0];
    }
    else {
    $link_image_source = get_term_meta( $terms[0]->term_id, 'single_image_taxonomy', true );
    }
    if ( !empty( $terms ) ){
    $term = array_shift( $terms );
    }
    ?>

    <div class="card-slider">
    ">
    </div>

    CSS

    .card-slider {
    position: relative;
    overflow: hidden;
    height: 300px;
    width: 100%;
    vertical-align: middle;
    }

    .thumbnail-cat {
    object-fit: cover;
    position: absolute;
    top: 0;
    height: 100%;
    width: 100%;
    }

Viewing 2 posts - 16 through 17 (of 17 total)