L
L
Lenwoot2016-06-11 11:15:15
PHP
Lenwoot, 2016-06-11 11:15:15

How to display records in the archive?

Hello, I have replaced the way to display posts in archives, now all posts from the site of all categories are displayed. For example: on a site of 2 categories, if you go to the archive of one, then the records of both are displayed. Also, if you go to the tag page, all tags are displayed. How to make accounting of categories and division by tags? Thank you.

<?php $posts = get_posts ('showposts=15&order=desc' . '&paged='.$paged); ?> 
<?php if ($posts) : ?>
<?php foreach ($posts as $post) : setup_postdata ($post); ?>


<div class="item col-lg-3 col-md-3 col-sm-12  ts-thumbnails-bellow">
<article class="post-70 video type-video status-publish has-post-thumbnail hentry tag-beautiful tag-buddypress tag-creative-video-theme tag-frontend-submission tag-touchsize tag-video tag-wordpress-themes tag-wordpress-video-theme videos_categories-cars">
<header><div class="image-holder">
<a href="<?php the_permalink() ?>">
<img class="lazy" alt="<?php the_title();?>" src="<?php the_post_thumbnail(); ?></a><a href="<?php the_permalink() ?>"><div class="rocky-effect"></a>
<div class="entry-overlay">
<div class="read-more"><div class="view-video-play">
<a href="<?php the_permalink() ?>"><i class="icon-play"></i></a></div></div><div class="overlay-sharing"></div></div></div>
</div>
</header>
<section><ul class="entry-meta-category" style="margin-right: 3px;"><li><a>link</a></li></ul>
<ul class="entry-meta-category"><li><?php the_field('years'); ?></li></ul>
<h3 class="entry-title">
<a class="entr572" href="<?php the_permalink() ?>"><?php the_title();?></a></h3>
</section>
</article></div>
<?php 
  endforeach;
  wp_reset_postdata();
?>
<?php endif; ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ruzhevich, 2016-06-16
@powepmakerru

if I understand the question correctly, then you need to display records from different categories in different places?
for example, you need to display a category with id 4, then it will work

<?php if ( have_posts() ) : 
  query_posts('cat=4');
  
  while ( have_posts() ) : the_post(); 
  
  if ($post->post_content == ""){
  
  ?>

<?php the_title() ?>

<?php the_content() ?>

<?php } 
 endwhile;
 endif;
 ?>

M
Mr Crabbz, 2016-06-11
@Punkie

Read about get_posts arguments: wp-kama.ru/function/get_posts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question