'publish',
'post_type' => 'post',
'posts_per_page' => 7,
'cat' => $blog_reflection_popular_news_category->term_id,
'ignore_sticky_posts' => 1,
];
$blog_reflection_most_popular_news_category_link = get_category_link($blog_reflection_popular_news_category->term_id);
$blog_reflection_popular_news_query = new WP_Query($blog_reflection_popular_news_post_args_2nd);
$i = 0;
if ($blog_reflection_popular_news_query->have_posts()) {
while ($blog_reflection_popular_news_query->have_posts()) {
$blog_reflection_popular_news_query->the_post();
$popular_news_post_img = (get_the_post_thumbnail_url(null, 'thumbnail')) ? get_the_post_thumbnail_url(null, 'thumbnail') : get_template_directory_uri() . '/assets/images/no-image.jpg';
// Get the post thumbnail ID
$popular_news_post_thumbnail_id = get_post_thumbnail_id(get_the_ID());
if (get_the_post_thumbnail_url()) {
$popular_news_image_alt_text = get_post_meta($popular_news_post_thumbnail_id, '_wp_attachment_image_alt', true);
} else {
$popular_news_image_alt_text = 'No Image';
}
// Example: Get random color for post tag
$trending_tag_colors = array(
'style-dark-green',
'style-red',
'style-blue'
);
$random_color = $trending_tag_colors[array_rand($trending_tag_colors)];
if (strlen(get_the_title()) > 5) {
// Trim to the first 5 characters and add ellipsis
$blog_reflection_most_popular_bottom_post_title = substr(get_the_title(), 0, 20) . '...';
} else {
// If the title is less than or equal to 5 characters, display it as is
$blog_reflection_most_popular_bottom_post_title = get_the_title();
}
$i++;
if ($i != 1) {
?>