Answer the question
In order to leave comments, you need to log in
How to make Output of entries from the same rubric as the current one, excluding the entry itself?
Good morning
I came across an article mywordpress.ru/support/viewtopic.php?id=24833&p=1
On the site, it was necessary to display similar posts from the same category as the post itself.
Everything seems to be working, but somehow crooked.
In some cases, there is a conclusion ONLY from the subheading. In another post, they are taken out of the general rubric.
Is there any way to make the output go ONLY from the general rubric?
And it is better if:
In a subheading - 2 records.
And in the general heading (together with other subheadings 6 entries)
So that posts from the subheadings are displayed first, and the next from the GENERAL.
But this is not necessary, it can be purely and simply from the GENERAL rubric.
<?php
$mycat=get_the_category();
$mycat=$mycat[0];
$posts = get_posts('numberposts=5&category='.$mycat->cat_ID.'&exclude='.$post->ID);
foreach($posts as $post) :?>
<li>
<a class="thumbpopular" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" ><?if(function_exists("has_post_thumbnail") && has_post_thumbnail()){the_post_thumbnail('sidebar70');}?></a>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
Answer the question
In order to leave comments, you need to log in
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array( 'cat' => 8, 'paged' => get_query_var('paged') )); ?>
could figure out how to exclude the current record from the results?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question