'post', 'post_status' => 'publish', 'posts_per_page' => 3, 'orderby' => 'date', // Order by the order of IDs in the array 'order' => 'asc', 'post__not_in' => $sticky_posts, // Exclude sticky posts ]; $home_two_left_hero_query = new WP_Query( $home_two_left_hero_args_latest ); } else { $home_two_left_hero_args_category = [ 'post_type' => 'post', 'category__in' => $left_hero_posts_cat, 'posts_per_page' => 3, 'orderby' => 'date', // Order by the order of IDs in the array 'order' => 'desc', 'post__not_in' => $sticky_posts, // Exclude sticky posts ]; $home_two_left_hero_query = new WP_Query( $home_two_left_hero_args_category ); } if ( $home_two_left_hero_query->have_posts() ) { $post_index = 0; while ( $home_two_left_hero_query->have_posts() ) { $home_two_left_hero_query->the_post(); // Get the categories of the specific post $home_two_left_hero_categories = get_the_category(); if ( ! empty( $home_two_left_hero_categories ) ) { // Assuming only one category per post $home_two_left_hero_category = $home_two_left_hero_categories[0]; // Selecting the first category // Get category link and color $blog_reflection_home_two_left_hero_category_link = get_category_link( $home_two_left_hero_category->term_id ); $home_two_left_hero_custom_field_cat_color = get_term_meta( $home_two_left_hero_category->term_id, 'term_color', true ); // Example: Get random color for post tag $tag_colors = array( 'style-dark-green', 'style-red', 'style-blue' ); $random_color = $tag_colors[ array_rand( $tag_colors ) ]; $home_two_left_hero_post_categories = $home_two_left_hero_category->name; } else { $blog_reflection_home_two_left_hero_category_link = ''; $home_two_left_hero_custom_field_cat_color = ''; $home_two_left_hero_post_categories = 'Uncategorized'; } $post_index ++; // Determine the column class based on the number of posts and their position if ( $post_count <= 2 ) { $col_class = 'col-12'; } elseif ( $post_count == 3 && $post_index <= 2 ) { $col_class = 'col-md-6'; if ( $col_class = 'col-md-6' ) { $hero_img_hight = 'hero-img-hight'; } } elseif ( $post_count == 3 && $post_index == 3 ) { $col_class = 'col-12'; } $blog_reflection_post_thumbnail_id = get_post_thumbnail_id( get_the_ID() ); if ( get_the_post_thumbnail_url() ) { $blog_reflection_image_alt_text = get_post_meta( $blog_reflection_post_thumbnail_id, '_wp_attachment_image_alt', true ); } else { $blog_reflection_image_alt_text = 'No Image'; } // Get post image URL $home_two_hero_left_post_img = ( get_the_post_thumbnail_url( null, 'large' ) ) ? get_the_post_thumbnail_url( null, 'large' ) : get_template_directory_uri() . '/assets/images/no-image.jpg'; if ( strlen( get_the_title() ) > 18 ) { // Trim to the first 5 characters and add ellipsis if ( $post_index == 3 ) { $blog_reflection_latest_hero_two_left_title = substr( get_the_title(), 0, 30 ) . '...'; } else { $blog_reflection_latest_hero_two_left_title = substr( get_the_title(), 0, 18 ) . '...'; } } else { // If the title is less than or equal to 5 characters, display it as is $blog_reflection_latest_hero_two_left_title = get_the_title(); } ?>
<?php echo esc_attr( $blog_reflection_image_alt_text ) ?>

'post', 'post_status' => 'publish', 'posts_per_page' => 3, 'orderby' => 'date', // Order by the order of IDs in the array 'order' => 'desc', 'post__not_in' => $sticky_posts, // Exclude sticky posts ]; $home_two_right_hero_query = new WP_Query( $home_two_right_hero_args_latest ); } else{ $home_two_right_hero_args_category = [ 'post_type' => 'post', 'post_status' => 'publish', 'category__in' => $right_hero_posts_cat, 'posts_per_page' => 3, 'orderby' => 'date', // Order by the order of IDs in the array 'order' => 'desc', 'post__not_in' => $sticky_posts, // Exclude sticky posts ]; $home_two_right_hero_query = new WP_Query( $home_two_right_hero_args_category ); } if ( $home_two_right_hero_query->have_posts() ) { $post_index = 0; while ( $home_two_right_hero_query->have_posts() ) { $home_two_right_hero_query->the_post(); // Get the categories of the specific post $home_two_left_hero_categories = get_the_category(); if ( ! empty( $home_two_left_hero_categories ) ) { // Assuming only one category per post $home_two_left_hero_category = $home_two_left_hero_categories[0]; // Selecting the first category // Get category link and color $blog_reflection_home_two_left_hero_category_link = get_category_link( $home_two_left_hero_category->term_id ); $home_two_left_hero_custom_field_cat_color = get_term_meta( $home_two_left_hero_category->term_id, 'term_color', true ); // Example: Get random color for post tag $tag_colors = array( 'style-dark-green', 'style-red', 'style-blue' ); $random_color = $tag_colors[ array_rand( $tag_colors ) ]; $home_two_left_hero_post_categories = $home_two_left_hero_category->name; } else { $blog_reflection_home_two_left_hero_category_link = ''; $home_two_left_hero_custom_field_cat_color = ''; $home_two_left_hero_post_categories = 'Uncategorized'; } $post_index ++; // Determine the column class based on the number of posts and their position if ( $post_count <= 2 ) { $col_class = 'col-12'; } elseif ( $post_count == 3 && $post_index == 1 ) { $col_class = 'col-12'; } elseif ( $post_count == 3 && $post_index > 1 ) { $col_class = 'col-md-6 '; $hero_img_hight = 'hero-img-hight'; } $blog_reflection_post_thumbnail_id = get_post_thumbnail_id( get_the_ID() ); if ( get_the_post_thumbnail_url() ) { $blog_reflection_image_alt_text = get_post_meta( $blog_reflection_post_thumbnail_id, '_wp_attachment_image_alt', true ); } else { $blog_reflection_image_alt_text = 'No Image'; } // Get post image URL $home_two_hero_right_post_img = ( get_the_post_thumbnail_url() ) ? get_the_post_thumbnail_url() : get_template_directory_uri() . '/assets/images/no-image.jpg'; if ( strlen( get_the_title() ) > 18 ) { // Trim to the first 5 characters and add ellipsis if ( $post_index == 3 ) { $blog_reflection_latest_hero_two_right_title = substr( get_the_title(), 0, 30 ) . '...'; } else { $blog_reflection_latest_hero_two_right_title = substr( get_the_title(), 0, 18 ) . '...'; } } else { // If the title is less than or equal to 5 characters, display it as is $blog_reflection_latest_hero_two_right_title = get_the_title(); } ?>
<?php echo esc_attr( $blog_reflection_image_alt_text ) ?>