| Server IP : 198.244.165.102 / Your IP : 216.73.216.218 [ Web Server : nginx/1.24.0 System : Linux modovh-ub-01 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64 User : colleary ( 1011) PHP Version : 8.3.23 Disable Function : NONE Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/midwest/public_html/wp-content/themes/midwest/ |
Upload File : |
<?php
/*
Template Name: Single Obituaries Template
*/
get_header();
?>
<?php get_template_part('template-parts/content', 'google-ads-top'); ?>
<!-- <div data-fuse="Obituarydetail_top_leaderboard"></div> -->
<section class="mid-content-wrap">
<div class="mid-content-container">
<div class="left-sidebar">
<!-- <div data-fuse="Article_sidebar_lhs" style="min-height: 600px;"></div> -->
</div>
<div class="container">
<div class="row">
<div class="col-md-12 mid-pad-ziro">
<div class="mid-home-slider-wrap mid-inner-news">
<div class="mid-home-slider-inner">
<div class="row">
<div class="col-md-12">
<div class="mid-inner-content-wrap">
<?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<!-- Image Wrapper -->
<div class="mid-obituary-single-img-wrap">
<div class="mid-obituary-single-img-inner">
<?php if (has_post_thumbnail()) {
the_post_thumbnail('full', ['class' => 'img-fluid']); // Featured image without a link
} else { ?>
<img src="/wp-content/uploads/2024/12/CANDLE.jpg" class="img-fluid" alt="<?php the_title(); ?>">
<?php } ?>
</div>
</div>
<div class="post_content_wrap">
<?php
$content = get_the_content(); // Get the raw post content.
$content = preg_replace('/style="[^"]*"/', '', $content); // Remove inline styles.
echo apply_filters('the_content', $content); // Apply WordPress content filters.
?>
</div>
<p class="obituary-date">
<span class="published">Published On: </span>
<?php
if (!function_exists('add_ordinal_suffix')) {
function add_ordinal_suffix($day) {
if ($day == 1 || $day == 21 || $day == 31) {
return $day . '<sup>st</sup>';
} elseif ($day == 2 || $day == 22) {
return $day . '<sup>nd</sup>';
} elseif ($day == 3 || $day == 23) {
return $day . '<sup>rd</sup>';
} else {
return $day . '<sup>th</sup>';
}
}
}
$day = get_the_date('j'); // Get the day without leading zeros
$month = get_the_date('F'); // Full month name
$year = get_the_date('Y'); // Full year
echo $month . ' ' . add_ordinal_suffix($day) . ', ' . $year;
?>
</p>
<?php endwhile;
endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="right-sidebar">
<!-- <div data-fuse="Article_sidebar_rhs" style="min-height: 600px;"></div> -->
</div>
</div>
</section>
<?php
$terms = get_the_terms(get_the_ID(), 'obituary-categories');
$show_section = false;
if ($terms && !is_wp_error($terms)) {
foreach ($terms as $term) {
if ($term->slug === 'past-death-notices' || $term->slug === 'death-notices') {
$show_section = true;
break;
}
}
}
if ($show_section && get_post_type() === 'obituaries') : ?>
<section class="mid-content-wrap" style="margin-top: 0;">
<div class="container">
<div class="row">
<div class="col-md-12 mid-pad--right-ziro">
<!-- News Slider Start -->
<div class="mid-home-slider-wrap mid-inner-news">
<div class="mid-home-slider-inner">
<div class="row">
<div class="col-md-12 mid-pad-ziro">
<div class="mid-inner-content-wrap">
<div class="condolences_outer">
<!-- Condolences Submission Form -->
<div id="condolence-wrapper">
<h3>Add a Condolence</h3>
<form id="condolence-form">
<?php if (!is_user_logged_in()) : ?>
<div class="form-group">
<label for="guest-name">Your Name</label>
<input type="text" name="guest_name" id="guest-name" class="form-control" required>
</div>
<?php endif; ?>
<div class="form-group">
<label for="condolence-message">Your Message</label>
<textarea name="condolence_message" id="condolence-message" class="form-control" rows="5" required></textarea>
</div>
<input type="hidden" name="related_obituary" value="<?php echo get_the_ID(); ?>" />
<input type="hidden" name="condolence_nonce" value="<?php echo wp_create_nonce('submit_condolence_nonce'); ?>" />
<button type="submit" class="btn btn-primary mid-view-all-btn">Submit Condolence</button>
</form>
</div>
<div id="condolence-response"></div>
</div>
<div class="condolences-section">
<h3>Condolences</h3>
<div class="pdf-download-button-wrap">
<button id="download-pdf-btn" class="btn btn-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="Download as PDF" data-orbituary-title="<?php the_title(); ?>">
<i class="fas fa-download"></i> <!-- Font Awesome download icon -->
</button>
</div>
</div>
<div class="condolence_form_outer">
<div class="condolences-list">
<?php
// Query for condolences related to this obituary
$args = array(
'post_type' => 'condolences',
'meta_query' => array(
array(
'key' => 'related_obituary', // Assuming you're using a custom field to link to the obituary
'value' => get_the_ID(),
'compare' => '='
),
),
);
$condolences_query = new WP_Query($args);
if ($condolences_query->have_posts()) : ?>
<?php while ($condolences_query->have_posts()) : $condolences_query->the_post(); ?>
<div class="row">
<div class="condolence-item">
<div class="condolence-details">
<div class="condolence-user-name">
<h5><?php the_title(); ?></h5>
</div>
<div class="condolence-date">
<?php
$condolence_time = get_the_time('U'); // Get the Unix timestamp for the condolence post
$current_time = current_time('timestamp'); // Current time
// Get human-readable time difference
$time_diff = human_time_diff($condolence_time, $current_time);
// Display "just now" if it's less than a minute old
if ($current_time - $condolence_time < 60) {
echo '<span>Just now</span>';
} else {
echo '<span>' . $time_diff . ' ago</span>';
}
?>
</div>
<div class="condolence-message">
<?php the_content(); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<p>No condolences have been added yet.</p>
<?php endif;
wp_reset_postdata(); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<?php endif; if ($show_section) : ?>
<section class="mid-content-wrap recent_obituaries_outer" style="margin-top: 0;">
<div class="container">
<div class="row">
<div class="col-md-12 mid-pad-ziro">
<!-- News Slider Start -->
<div class="mid-home-slider-wrap mid-pad--right-ziro mid-inner-news mid-obituary-wrap" style="padding-bottom: 45px !important;">
<div class="mid-title-wrap">
<h3>Recent Obituaries</h3>
</div>
<div class="mid-home-slider-inner">
<div class="owl-carousel owl-theme">
<?php
$args = [
'post_type' => 'obituaries',
'posts_per_page' => 5,
'tax_query' => [
[
'taxonomy' => 'obituary-categories',
'field' => 'slug',
'terms' => 'death-notices',
]
],
'orderby' => 'date',
'order' => 'DESC',
'post_status' => 'publish',
'post__not_in' => [get_the_ID()], // Exclude the current obituary
];
$recent_obituaries = new WP_Query($args);
if ($recent_obituaries->have_posts()):
while ($recent_obituaries->have_posts()): $recent_obituaries->the_post(); ?>
<div class="item">
<div class="card">
<div class="mid-obituary-card-img-wrap">
<div class="rounded-image">
<div class="rounded-image-inner">
<?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>">
<img src="<?php the_post_thumbnail_url('medium'); ?>" class="card-img-top" alt="<?php the_title(); ?>">
</a>
<?php else : ?>
<a href="<?php the_permalink(); ?>">
<img src="/wp-content/uploads/2024/12/CANDLE.jpg" class="card-img-top" alt="Candle Image">
</a>
<?php endif; ?>
</div>
</div>
</div>
<div class="card-body">
<h4 class="card-title two-line-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h4>
<p class="card-text three-line-text"><?php echo wp_trim_words(get_the_excerpt(), 10, '...'); ?></p>
<p class="obituary-date">
<span class="published">Published On: </span>
<?php
if (!function_exists('add_ordinal_suffix')) {
function add_ordinal_suffix($day) {
if (in_array($day, [1, 21, 31])) return $day . '<sup>st</sup>';
if (in_array($day, [2, 22])) return $day . '<sup>nd</sup>';
if (in_array($day, [3, 23])) return $day . '<sup>rd</sup>';
return $day . '<sup>th</sup>';
}
}
echo get_the_date('F ') . add_ordinal_suffix(get_the_date('j')) . ', ' . get_the_date('Y');
?>
</p>
<a href="<?php the_permalink(); ?>" class="btn btn-primary mid-read-more-btn">read more <i class="fa-solid fa-plus"></i></a>
</div>
</div>
</div>
<?php endwhile;
wp_reset_postdata();
endif; ?>
</div>
</div>
</div>
<!-- News Slider End -->
</div>
</div>
</div>
<br><br>
</section>
<?php endif; ?>
<!-- <div data-fuse="Obituarydetail_bottom_leaderboard"></div> -->
<?php get_template_part('template-parts/content', 'google-ads-bottom'); ?>
<?php get_footer('inner'); ?>