SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Only show certain rss feeds

    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 Code:
    <?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;
    }
    ?>

  2. #2
    SitePoint Member jacksters's Avatar
    Join Date
    Dec 2011
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use RSS Channel Writer to solve this problem.

  3. #3
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't believe I need to buy a piece of software to do this.

    Thanks for your suggestion though.

  4. #4
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just had to dig a little deeper into the codex to get the top level (parent) categories only.

    This works:

    PHP Code:
    <?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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •