<?php
/*
Template Name: Вывод записей категории
*/
?>
<?php get_header(); ?>
<div class="cols wr-content">
<div class="col col_left">
<?php get_sidebar('left'); ?>
</div>
<div class="col col_right clearfix">
<div class="col_wrapper">
<div class="l_block">
<article class="content" role="main">
<div class="vert_uzor left"></div>
<div class="vert_uzor right"></div>
<div class="breadcrumbs">
<ul class="breadcrumbs"><?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?>
</ul>
</div>
<?php
$query = new WP_Query( 'cat=2&posts_per_page=3' );
if( $query->have_posts() ){
while( $query->have_posts() ){
$query->the_post();
?>
<div class="all-news">
<div class="all-news-item cf">
<span class="all-news-item-date"><?php the_time('l | d.m.Y') ?></span>
<div class="all-news-item-img">
<a href="<?php the_permalink() ?>"
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'medium' ); //get full URL to image (use "large" or "medium" if the images too big)
$image = aq_resize( $img_url, 333);
if($image) : ?> <a href="<?php the_permalink(); ?>"><img src="<?php echo $image ?>"/></a>
<?php endif; ?>
</a><br/>
</div>
<div class="all-news-item-content">
<h6><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a><br/></h6>
<p><?php the_excerpt(); ?></p><br /><br />
<div class="btn-more"><br><a href="<?php the_permalink() ?>"><u>Подробнее</u></a></div>
</div>
</div>
</div>
<?php
}
wp_reset_query(); // сбрасываем переменную $post
}
else
echo 'Записей нет.';
?>
<div class="pagin">
<nav class="navigation pagination" >
<div class="nav-links">
<?php wp_pagenavi(); ?>
</div>
</nav>
</div>
</article>
</div>
</div>
<?php get_sidebar('right'); ?>
</div>
</div>
</div><!-- cols -->
</div><!-- container -->
</div><!-- maincontent -->
<?php get_footer(); ?>
<?php
/*
Template Name: Вывод записей категории
*/
?>
<?php get_header(); ?>
<div class="cols wr-content">
<div class="col col_left">
<?php get_sidebar('left'); ?>
</div>
<div class="col col_right clearfix">
<div class="col_wrapper">
<div class="l_block">
<article class="content" role="main">
<div class="vert_uzor left"></div>
<div class="vert_uzor right"></div>
<div class="breadcrumbs">
<ul class="breadcrumbs"><?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?>
</ul>
</div>
<div class="all-news">
<?php
$count_items = 5;//кол-во выводимых элементов
$paged = get_query_var( 'paged', 1 );//Получаем текущую страницу
$id = get_category_by_slug( 'news' )->cat_ID;//получаем id рубрики.рубрика новости.
$recent = new WP_Query( "cat=$id&posts_per_page=$count_items&paged=$paged" );//Сам запрос
while ( $recent->have_posts() ) {
$recent->the_post();
?>
<div class="all-news-item cf">
<span class="all-news-item-date"><?php the_time('l | d.m.Y') ?></span>
<div class="all-news-item-img">
<a href="<?php the_permalink() ?>"
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'medium' ); //get full URL to image (use "large" or "medium" if the images too big)
$image = aq_resize( $img_url, 333);
if($image) : ?> <a href="<?php the_permalink(); ?>"><img src="<?php echo $image ?>"/></a>
<?php endif; ?>
</a><br/>
</div>
<div class="all-news-item-content">
<h6><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a><br/></h6>
<p><?php the_excerpt(); ?></p><br /><br />
<div class="btn-more"><br><a href="<?php the_permalink() ?>"><u>Подробнее</u></a></div>
</div>
</div>
<?php
}
wp_reset_postdata();
?>
</div>
<div class="pagin">
<nav class="navigation pagination" >
<div class="nav-links">
<?php
wp_pagenavi( array( 'query' => $recent ) );//вывод пагинации.
?>
</div>
</nav>
</div>
</article>
</div>
</div>
<?php get_sidebar('right'); ?>
</div>
</div>
</div><!-- cols -->
</div><!-- container -->
</div><!-- maincontent -->
<?php get_footer(); ?>