<?php
global $post;

// Get the faculty category (taxonomy term) link
$terms = get_the_terms($post->ID, 'faculty_category');
$category_link = '';
if ($terms && !is_wp_error($terms)) {
    $term = current($terms);
    $category_link = get_term_link($term);
}
?>
<div class="col-md-4">
    <div class="faculties">
        <div class="mx-2 mt-4">
            <div class="common-bg-color card rounded-0 overflow-hidden">
                <?php if (has_post_thumbnail($post->ID)) :
                    $imageInfo = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
                    $imageUrl = $imageInfo[0]; ?>

                    <img src="<?php echo $imageUrl ?>" class="academic-image" alt="<?php the_title(); ?>">
                <?php
                else:
                    ?>
                    <img src="<?php echo get_site_url(); ?>/wp-content/uploads/2025/07/fff.png"
                         class="academic-image" alt="<?php the_title(); ?>">
                <?php
                endif;
                ?>
                <div class="card-body academicAbout">
                    <a class="faculty_title"
                       href="<?php the_permalink(); ?>">
                        <h3 class="card-title text-white fs-5 text-center"
                            style="text-shadow: 0px 3px 4px rgb(0 0 0 / 25%);">
                            <?php the_title(); ?>
                        </h3>
                    </a>

                    <div class="pt-3"
                         style="color: #ffffffc7;">
                        <?php
                        /**
                         * Custom Excerpt Length WordPress using wp_trim_excerpt()
                         * Use directly in template
                         */
                        $content = get_the_content();
                        echo '<p style="text-align:justify">' . wp_trim_words($content, '15') . '</p>';
                        ?>
                    </div>
                    <a class="text-white academics_details"
                       href="<?php the_permalink(); ?>">
                        <h3
                                class="text-uppercase d-flex align-items-center justify-content-end mb-0">
                            Find More<i class="bi bi-arrow-right mx-2"></i>
                        </h3>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>