I am showing a feed for all categories and sub-categories. Is there a way to only show the parent category or selected categories?
<?php
$myitem ='';
$mycats= get_categories();
foreach($mycats as $mycat) {
$myitem = '<li><a title="Subscribe to the '.$mycat->name.' news feed" href="'.get_bloginfo('url').'/category/'.$mycat->category_nicename.'/feed/">'.$mycat->name.'</a></li>';
echo $myitem;
}
?>
Use RSS Channel Writer to solve this problem.
I don’t believe I need to buy a piece of software to do this.
Thanks for your suggestion though.
Just had to dig a little deeper into the codex to get the top level (parent) categories only.
This works:
<?php
$myitem ='';
$mycats= get_categories('include=3,4,5,6,8,9,16');
foreach($mycats as $mycat) {
$myitem = '<li><a title="Subscribe to the '.$mycat->name.' news feed" href="'.get_bloginfo('url').'/category/'.$mycat->category_nicename.'/feed/">'.$mycat->name.'</a></li>';
echo $myitem;
}
?>
exclude=‘’ also works, to exclude child categories.