WordPress.org

Support

Support » How-To and Troubleshooting » display lists of categories an author has written a post in

display lists of categories an author has written a post in

  • Hello!
    my website: ampersandbox.net/?author=2

    Basically on every author’s page I would like to display a list on the right side of categories the current author has contributed to (has written a post in)

    I’m not sure how to go about this but I started trying to write some code I came up with this code but for some reason it only displays one category which happens to be category 2. (check column on right labeled CATEGORIES)

    <?php
    //Gets category and author info
      global $wp_query;
    $cats = get_the_category();
      $postAuthor = $wp_query->post->post_author;
    $tempQuery = $wp_query;
    // related category posts
      $catlist = "";
      forEach( $cats as $c ) {
      if( $catlist != "" ) { $catlist .= ","; }
      $catlist .= $c->name;
      $catlist .= $c->description;
      }
      $newQuery = "posts_per_page=5&cat=" . $catlist;
      query_posts( $newQuery );
    $categoryPosts = "";
      $count = 0;
      ?>
    <?php echo $catname .' '. $catlist; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘display lists of categories an author has written a post in’ is closed to new replies.