In a single.php, I am trying to write a code which shows excerpts from all categories that a single post belongs to. However. I cannot complete the code.
It should look like this.
-----------------------------------
main article
<h2>category 1</h2>
-excerpt1
-excerpt2
-excerpt3
<h2>category 2</h2>
-excerpt4
-excerpt5
-excerpt6
-excerpt7
footer
------------------------------------
this is what I get so far.
<?php $categories = get_the_category();
foreach($categories as $category):
$related_posts = get_posts('category='.$category->cat_ID.'&exclude='.$post->ID.'&numberposts=-1');
if($related_posts): ?>
<h2><?php echo $category->cat_name; ?> category <h2>
<?php foreach($related_posts as $related_post): ?>
<div id="entry<?php get_the_ID($related_post); ?>">
<?php get_the_excerpt($related_post); ?>
</div>
<?php endforeach; ?>
<?php endif; endforeach; ?>
Any help or pointers to possible solutions is greatly appreciated.