File: /var/www/html/acharya-rajnikant-backup/wp-content/themes/aacharyarajnikant/sermon.php
<?php
/**
* Template Name: Sermon Page
*/
get_header(); ?>
<!-- ================> Sermon section start here <================== -->
<div class="sermon padding--top padding--bottom bg-light">
<div class="container">
<div class="section__wrapper">
<div class="row g-4">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'sermon',
'posts_per_page' => 6,
'paged' => $paged
);
$sermon_query = new WP_Query($args);
if ($sermon_query->have_posts()) :
while ($sermon_query->have_posts()) : $sermon_query->the_post();
$video = get_field('video_url');
$audio = get_field('audio_url');
$pdf = get_field('pdf_url');
$gallery = get_field('gallery_url');
$image = get_the_post_thumbnail_url(get_the_ID(), 'full');
?>
<div class="col-lg-6 col-12">
<div class="sermon__item">
<div class="sermon__inner">
<div class="sermon__thumb">
<?php if ($image) : ?>
<img src="<?php echo esc_url($image); ?>" alt="<?php the_title_attribute(); ?>">
<?php else : ?>
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/sermon/01.jpg" alt="sermon thumb">
<?php endif; ?>
</div>
<div class="sermon__content">
<h6><?php the_title(); ?></h6>
<ul class="sermon__content-metapost">
<li><i class="far fa-calendar"></i> <?php echo get_the_date(); ?></li>
<li><i class="fas fa-user"></i> <?php the_author(); ?></li>
</ul>
<ul class="sermon__content-social">
<?php if ($video) : ?>
<li><a href="<?php echo esc_url($video); ?>"><i class="fas fa-video"></i></a></li>
<?php endif; ?>
<?php if ($audio) : ?>
<li><a href="<?php echo esc_url($audio); ?>"><i class="fas fa-headphones-alt"></i></a></li>
<?php endif; ?>
<?php if ($pdf) : ?>
<li><a href="<?php echo esc_url($pdf); ?>"><i class="fas fa-file-alt"></i></a></li>
<?php endif; ?>
<?php if ($gallery) : ?>
<li><a href="<?php echo esc_url($gallery); ?>"><i class="fas fa-image"></i></a></li>
<?php endif; ?>
</ul>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<div class="col-12 mt-5">
<div class="pagination-area d-flex flex-wrap justify-content-center">
<?php
echo paginate_links(array(
'total' => $sermon_query->max_num_pages,
'current' => $paged,
'prev_text' => '<i class="fas fa-angle-double-left"></i>',
'next_text' => '<i class="fas fa-angle-double-right"></i>',
));
?>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<div class="col-12">
<p class="text-center">No sermons found.</p>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<!-- ================> Sermon section end here <================== -->
<?php get_footer(); ?>