<?php
$myposts = get_posts([
'numberposts' => 10,
'post_type'=> 'team'
]);
$ir = 0;
?>
<?php foreach( $myposts as $post ) :
setup_postdata( $post );
?>
<?php if ($ir % 2 == 0) : ?>
<div class="slide">
<?php endif; ?>
<div class="post">
<h3><?php the_title(); ?></h3>
<a class="box-post_link" href="<?php echo get_permalink(); ?>">Читать дальше </a>
</div>
<?php if ($ir % 2 !== 0) : ?>
</div >
<?php endif; $ir++; ?>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
/**
* Load different template for sub category
*/
function sub_category_template() {
// Get the category id from global query variables
$cat = get_query_var('cat');
if(!empty($cat)) {
// Get the detailed category object
$category = get_category($cat);
// Check if it is sub-category and having a parent, also check if the template file exists
if( ($category->parent != '0') && (file_exists(TEMPLATEPATH . '/sub-category-template.php')) ) {
// Include the template for sub-catgeory
include(TEMPLATEPATH . '/sub-category-template.php');
exit;
}
return;
}
return;
}
add_action('template_redirect', 'sub_category_template');