Fall back to excerpt if card description is missing

This commit is contained in:
Tetrakern 2024-07-20 23:13:26 +02:00
parent fc96d38f03
commit 4715fea1ee
2 changed files with 7 additions and 9 deletions

View File

@ -20,7 +20,10 @@ defined( 'ABSPATH' ) OR exit;
$post_id = $post->ID;
$list_title = trim( get_post_meta( $post_id, 'fictioneer_collection_list_title', true ) );
$title = empty( $list_title ) ? fictioneer_get_safe_title( $post_id, 'card-collection' ) : $list_title;
$description = fictioneer_get_content_field( 'fictioneer_collection_description', $post_id );
$excerpt = fictioneer_first_paragraph_as_excerpt(
fictioneer_get_content_field( 'fictioneer_collection_description', $post_id )
);
$excerpt = empty( $excerpt ) ? fictioneer_get_excerpt( $post_id ) : $excerpt;
$statistics = fictioneer_get_collection_statistics( $post_id );
$items = get_post_meta( $post_id, 'fictioneer_collection_items', true );
$items = empty( $items ) ? [] : $items;
@ -67,11 +70,6 @@ if ( ! empty( $items ) ) {
$items = $items->posts;
}
// Last rescue for empty description
if ( empty( $description ) ) {
$description = __( 'No description provided yet.', 'fictioneer' );
}
// Extra classes
if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
$card_classes[] = '_' . get_theme_mod( 'card_style' );
@ -131,7 +129,7 @@ $thumbnail_args = array(
printf(
'<div class="card__content cell-desc"><div class="truncate %1$s"><span>%2$s</span></div></div>',
count( $items ) > 2 ? '_cq-4-3' : '_4-4',
fictioneer_truncate( $description, 512 )
fictioneer_truncate( $excerpt ?: __( 'No description provided yet.', 'fictioneer' ), 512 )
);
?>

View File

@ -28,7 +28,7 @@ $chapter_count = count( $chapter_ids );
$excerpt = fictioneer_first_paragraph_as_excerpt(
fictioneer_get_content_field( 'fictioneer_story_short_description', $post_id )
);
$excerpt = empty( $excerpt ) ? __( 'No description provided yet.', 'fictioneer' ) : $excerpt;
$excerpt = empty( $excerpt ) ? fictioneer_get_excerpt( $post_id ) : $excerpt;
$tags = false;
$card_classes = [];
@ -129,7 +129,7 @@ $thumbnail_args = array(
fictioneer_get_author_node()
)
),
$excerpt
$excerpt ?: __( 'No description provided yet.', 'fictioneer' )
);
?>