WordPress.org

Ready to get started?Download WordPress

Forums

[closed] display lists of categories an author has written a post in (2 posts)

  1. Kevin Kwok
    Member
    Posted 4 years ago #

    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; ?>
  2. MichaelH
    Member
    Posted 4 years ago #

    Dupicate...continue discussion here:
    http://wordpress.org/support/topic/327333

    Please don't post duplicate topics. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic