From c6079830f096593ec475b5adb5c440cc280d454b Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Mon, 6 Apr 2026 00:27:52 +0700 Subject: [PATCH] feat: display AI summary and keyword tags on frontend --- public/class-peptide-news-public.php | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/public/class-peptide-news-public.php b/public/class-peptide-news-public.php index 275af3a..24db92d 100644 --- a/public/class-peptide-news-public.php +++ b/public/class-peptide-news-public.php @@ -131,7 +131,11 @@ class Peptide_News_Public {

- excerpt ); ?> + ai_summary ) ? $article->ai_summary : $article->excerpt; + echo esc_html( $display_text ); + ?>

author ) ) : ?> @@ -140,14 +144,17 @@ class Peptide_News_Public { - categories ) ) : ?> + tags ) ? $article->tags : ( $article->categories ?? '' ); + if ( ! empty( $tag_source ) ) : ?>
categories ) ); - foreach ( array_slice( $cats, 0, 3 ) as $cat ) : - if ( empty( $cat ) ) continue; + $tag_items = array_map( 'trim', explode( ',', $tag_source ) ); + foreach ( array_slice( $tag_items, 0, 5 ) as $tag_item ) : + if ( empty( $tag_item ) ) continue; ?> - +
@@ -217,13 +224,13 @@ class Peptide_News_Public { } $articles = $wpdb->get_results( $wpdb->prepare( - "SELECT id, source, source_url, title, excerpt, author, thumbnail_url, - published_at, categories + "SELECT id, source, source_url, title, excerpt, ai_summary, author, thumbnail_url, + published_at, categories, tags FROM {$table} WHERE is_active = 1 ORDER BY published_at DESC LIMIT %d", - $count + $count ) ); // Cache for 5 minutes. @@ -290,7 +297,7 @@ class Peptide_News_Widget extends WP_Widget { $count = isset( $instance['count'] ) ? absint( $instance['count'] ) : 5; echo $args['before_widget']; - + if ( $title ) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; } @@ -315,7 +322,7 @@ class Peptide_News_Widget extends WP_Widget {