Card Block

The tenrec/card ACF block — one field per arg the Card molecule accepts, for dropping a single card in anywhere the card grid organisms don't already cover.

This entry previews the block's field-to-molecule mapping via the Playground below (image omitted — see the note above). The static example shows the with-image variant, exercising the Image and Image Ratio fields the Playground can't.

Playground

Change a value below to update the preview live.

Usage

// blocks/card/template.php: when "Reference Existing Content" is off, every ACF field maps
// 1:1 onto the Card molecule's own args, same as before. When it's on, Title/Image/Content/Link
// are instead derived from the "Related Content" post_object selection — Date, Eyebrow, and
// Heading Level stay manually editable either way:
if ( get_field( 'use_relationship' ) && ( $related = get_field( 'related_content' ) ) ) {
    $mapped_args = [
        'title'     => get_the_title( $related ),
        'image'     => get_post_thumbnail_id( $related ),
        'content'   => get_the_excerpt( $related ),
        'link_url'  => get_permalink( $related ),
        'link_text' => __( 'View more', 'lusso' ),
    ];
} else {
    $mapped_args = [
        'title'           => get_field( 'title' ),
        'image'           => get_field( 'image' )['ID'] ?? 0,
        'content'         => get_field( 'content' ),
        'link_url'        => get_field( 'link' )['url'] ?? '',
        'link_text'       => get_field( 'link' )['title'] ?? '',
        'link_aria_label' => get_field( 'link_aria_label' ), // optional — auto-derived if left blank
    ];
}

get_template_part( 'template-parts/molecules/card', null, array_merge( $mapped_args, [
    'image_ratio'   => get_field( 'image_ratio' ), // '' | 16/9 | 4/3 | 1/1 | 3/2, default '' (4/3)
    'date'          => get_field( 'date' ),
    'eyebrow'       => get_field( 'eyebrow' ),
    'heading_level' => get_field( 'heading_level' ), // h2 | h3 | h4, default h3
] ) );