• Resolved Alex Volkov

    (@vol4ikman)


    Hi,
    how can I show X posts from current category and exclude current post?

    this solution shows to me all posts from current category:

    <?php
    	global $post;
    	$categories = get_the_category();
    
    	foreach ($categories as $category) :?>
    
    		<h3>More News From This Category</h3>
    		<ul>
    
    		<?php
    			$posts = get_posts('numberposts=3&category='. $category->term_id);
    			foreach($posts as $post) : ?>
    
    			<li>
    				<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    			</li>
    
    		<?php endforeach; ?>
    
    			<li><strong><a href="<?php echo get_category_link($category->term_id);?>" title="View all posts filed under <?php echo $category->name; ?>">ARCHIVE FOR '<?php echo $category->name; ?>' CATEGORY ?</a></strong></li>
    
    <?php endforeach; ?>
    
    		</ul>

    But I need to exclude current post

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show posts from current category and exclude current post’ is closed to new replies.