83 lines
3.1 KiB
PHP
83 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* Category Template
|
|
*/
|
|
|
|
get_header();
|
|
|
|
$company_logo = get_field('company_logo', 'option');
|
|
?>
|
|
|
|
<section class="category-page-container">
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="mb-5 category-title">
|
|
<h1 class="text-center"><?php echo single_cat_title(); ?></h1>
|
|
</div>
|
|
</div>
|
|
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
|
|
<div class="row d-flex justify-content-center align-items-center gy-5 post-item">
|
|
<div class="col-4">
|
|
<div class="post-img">
|
|
<?php
|
|
$image_id = get_the_post_thumbnail( $post->ID, 'medium' );
|
|
$alt_text = get_post_meta( get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true );
|
|
?>
|
|
<?php if( !empty(get_the_post_thumbnail()) ) : ?>
|
|
<img class="img-fluid" src="<?php echo the_post_thumbnail_url( $image_id, 'medium' ); ?>" alt="<?php echo $alt_text; ?>" />
|
|
<?php else : ?>
|
|
<div class="d-flex justify-content-center align-items-center img-placeholder">
|
|
<img class="img-fluid" src="<?php echo $company_logo['url']; ?>" alt="<?php echo $company_logo['alt'] ?>" />
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="post-content">
|
|
<small><?php the_time('F jS, Y') ?></small>
|
|
<a href="<?php the_permalink(); ?>">
|
|
<h4><?php echo the_title(); ?></h4>
|
|
</a>
|
|
<p><?php the_excerpt(); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endwhile; ?>
|
|
|
|
</div>
|
|
|
|
<?php else: ?>
|
|
<p class="text-center">Sorry, no posts matched your criteria.</p>
|
|
<?php endif; ?>
|
|
</section>
|
|
|
|
<!-- Category section BEGIN -->
|
|
<section class="container pb-4 post-categories-container">
|
|
<?php
|
|
$category_name = $category->name;
|
|
$categories = get_categories( array(
|
|
'taxonomy' => 'category',
|
|
'orderby' => 'name',
|
|
'parent' => 0,
|
|
'hide_empty' => 0,
|
|
) );
|
|
?>
|
|
<div class="row">
|
|
<div class="col">
|
|
<h3 class="category-title">Explore more topics:</h3>
|
|
</div>
|
|
</div>
|
|
<div class="row post-category-list">
|
|
<?php foreach($categories as $category) {
|
|
$category_name = $category->name;
|
|
if( strtolower( $category_name ) != 'uncategorized' ) { ?>
|
|
<div class="col-12 col-md-4">
|
|
<h4 class="category-item"><a href="<?php echo esc_url( get_category_link( $category->term_id ) ); ?>"><?php echo $category->name; ?></a></h4>
|
|
</div>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</div>
|
|
</section>
|
|
<!-- Category section END -->
|
|
|
|
<?php get_footer(); ?>
|