FEATURE Enhance post-card component to support external links with customizable target attributes
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e6f1a60a9d
commit
b9faf3ba7a
|
|
@ -6,8 +6,14 @@ $showExcerpt = $args['show_excerpt'] ?? false;
|
|||
|
||||
$showTags = $args['showTags'] ?? true;
|
||||
|
||||
$has_external_link = $args['has_external_link'] ?? false;
|
||||
$external_link = $args['external_link'] ?? null;
|
||||
$external_link_text = $args['external_link_text'] ?? null;
|
||||
|
||||
$target = $has_external_link && ! empty($external_link) ? '_blank' : '_self';
|
||||
|
||||
$excerpt = get_the_excerpt($ID);
|
||||
$link = get_the_permalink($ID);
|
||||
$link = ($has_external_link && ! empty($external_link)) ? $external_link : get_the_permalink($ID);
|
||||
|
||||
$has_post_thumbnail = has_post_thumbnail($ID);
|
||||
$thumbnail_url = get_the_post_thumbnail_url($ID) ?? null;
|
||||
|
|
@ -23,14 +29,12 @@ $editors = get_field('editors', $ID);
|
|||
$has_publication_direction = get_field('has_publication_direction', $ID);
|
||||
$publication_directors = get_field('publication_directors', $ID);
|
||||
|
||||
|
||||
$numerotation = get_post_meta($ID, 'post_numerotation', true);
|
||||
$tags = get_the_terms($ID, 'etiquettes');
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<a class="post-card post-card--<?php echo $current_post_type . ' ' . ($has_post_thumbnail ? 'post-card--has-thumbnail' : ''); ?> card" href="<?php echo $link; ?> ">
|
||||
<a class="post-card post-card--<?php echo $current_post_type . ' ' . ($has_post_thumbnail ? 'post-card--has-thumbnail' : ''); ?> card" href="<?php echo esc_url($link); ?>" target="<?php echo $target; ?>">
|
||||
<?php if ($has_post_thumbnail) : ?>
|
||||
<div class="post-card__thumbnail">
|
||||
<img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user