File: /home/rassvet-tk.ru/public_html/wp-content/themes/rassvettk/category.php
<? get_header(); ?>
<?
$term = get_queried_object();
$current_category = $term->cat_ID;
//echo '<div><pre>',print_r($term),'</pre></div>';
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
?>
<section id="main">
<div class="container">
<div class="col-md-12">
<div class="row" style="margin-bottom: 50px;">
<div class="col-md-12">
<h1 class="main_p"><?= $term->name; ?></h1>
<hr class="hr_left">
</div>
</div>
<div style="display: flex;justify-content: start;margin-bottom: 30px;">
<?
$categories = get_categories( [
'taxonomy' => 'category',
'type' => 'post',
'parent' => 3,
'hide_empty' => 0
] );
foreach( $categories as $category ) :
$id = $category->taxonomy . '_' . $category->term_id;
$image = get_field('izobrazhenie', $id);
echo '
<div class="button_dalee" style="margin-right: 10px;">
<a href="' . get_category_link( $category->term_id ) . '" style="font-size: 18px;">' . $category->name.'</a>
</div>
';
endforeach;
?>
</div>
<? if($term->parent === 0): ?>
<?
$args = array(
'posts_per_page' => -1,
'post_type' => 'post',
'cat' => 3,
'post_status' => 'publish',
'orderby' => 'publish_date',
'order' => 'desc'
);
$query = new WP_Query( $args );
if ( $query->have_posts() ):
?>
<?
while ( $query->have_posts() ):
$query->the_post();
?>
<div class="row">
<div class="col-md-12">
<div class="material_box blog_css">
<a href="<? the_permalink(); ?>"><? if(get_the_post_thumbnail_url()): ?><img src="<?= get_the_post_thumbnail_url(); ?>" alt="<? the_title(); ?>"><? endif; ?></a>
<a href="<? the_permalink(); ?>"><p style="color: black; font-size: 18px;"><? the_title(); ?></p></a>
<span><?= get_the_date() ?></span> <br>
<div class="button_dalee" style="text-align: right;"><a href="<? the_permalink(); ?>" style="font-size: 18px;">Читать далее</a></div>
</div>
</div>
</div>
<? endwhile; ?>
<?
endif;
wp_reset_postdata();
?>
<? else: ?>
<?
$args = array(
'posts_per_page' => -1,
'post_type' => 'post',
'cat' => $current_category,
'post_status' => 'publish',
'orderby' => 'publish_date',
'order' => 'desc'
);
$query = new WP_Query( $args );
if ( $query->have_posts() ):
?>
<?
while ( $query->have_posts() ):
$query->the_post();
?>
<div class="row">
<div class="col-md-12">
<div class="material_box blog_css">
<a href="<? the_permalink(); ?>"><? if(get_the_post_thumbnail_url()): ?><img src="<?= get_the_post_thumbnail_url(); ?>" alt="<? the_title(); ?>"><? endif; ?></a>
<a href="<? the_permalink(); ?>"><p style="color: black; font-size: 18px;"><? the_title(); ?></p></a>
<span><?= get_the_date() ?></span> <br>
<div class="button_dalee" style="text-align: right;"><a href="<? the_permalink(); ?>" style="font-size: 18px;">Читать далее</a></div>
</div>
</div>
</div>
<? endwhile; ?>
<?
endif;
wp_reset_postdata();
?>
<? endif; ?>
</div>
</div>
</section>
<? get_footer(); ?>