hi! I'm a dummy user with wordpress.
In a sidebar, I'm trying to insert a code that shows a list of the posts of a current category (the category of the post where I am).
Now the code is:
<?php if(is_category() || is_single()){
global $post;
foreach(get_the_category() as $category)
{
$current = $category->cat_ID;
$current_name = $category->cat_name;
}
}
echo $current_name . " has id ".$current;
$myposts = get_posts('numberposts=50&category='.$current);
foreach($myposts as $post) : ?>
<li>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a>
</li>
<?php endforeach; ?>
Actually it doeasn't work correctly, because it show me more than the post really in the current category. Why?
I have to exclude parent and child category?
How can I do?
Can You help me please?
thanks, Marco