logo

$20
Custom Post Type Authors Page

I'm trying to create a simple authors page restricted to a specific (custom) post type. I would like to display each author, some of their basic meta data (name, bio), and links to the posts of the specified type credited to them (X most recent if possible). Thanks!

Adam Bundy | 07/27/10 at 10:50am | Edit


(2) Possible Answers Submitted...

  • avatar
    Last edited:
    07/27/10
    10:55am
    Pippin Williamson says:

    This is the link you need.

    http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html

    If you need help implementing it, let me know at pippin@pippinspages.com

    • 07/27/10 11:02am

      Adam Bundy says:

      Pippin thanks but Im actually looking to create a page that lists ALL authors, some info and links to the posts (custom post type) they're owners of, not an 'about the author' box. Thanks though!

  • avatar
    Last edited:
    07/27/10
    1:49pm
    Aneesh Joseph says:

    <?php
    require('/the/path/to/your/wp-blog-header.php');
    ?>

    <?php get_header(); ?>
    <div id="contet">
    <?php $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");
    <!-- loop for authors -->
    foreach($authors as $author) {
    $curauth = get_userdata(intval($author->ID));
    ?>



    <h2>About: <?php echo $curauth->nickname; ?></h2>
    <dl>
    <dt>Website</dt>
    <dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>
    <dt>Profile</dt>
    <dd><?php echo $curauth->user_description; ?></dd>
    </dl>

    <h2>Posts by <?php echo $curauth->nickname; ?>:</h2>

    <ul>
    <!-- Posts Loop -->


    <?php query_posts('author='.$author->ID.'&showposts=5'); while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a></li>
    <?php endwhile; ?>


    <!-- /Posts Loop -->

    </ul>

    <?php } ?>
    <!-- /loop for authors -->

    </div>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>


    Use this php file after editing it with proper path to wp-blog-header.php and try accessing this via your browser :)

    If you want to give a nice Permalink to this page, then use htaccess rewrite rules :)

    Previous versions of this answer: 07/27/10 at 12:09pm | 07/27/10 at 12:11pm

    • 07/27/10 12:05pm

      Adam Bundy says:

      Aneesh, this is really close, but I need to restrict the query_posts to a custom type (iW_post), which Ive tried to do here, but the output shows the same 5 posts for each author. Can you help get the custom type integrated? Thanks!


      <?php $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");
      foreach($authors as $author) {
      $curauth = get_userdata(intval($author->ID));
      ?>

      <h2>About: <?php echo $curauth->nickname; ?></h2>
      <dl>
      <dt>Website</dt>
      <dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>
      <dt>Profile</dt>
      <dd><?php echo $curauth->user_description; ?></dd>
      </dl>

      <h2>Posts by <?php echo $curauth->nickname; ?>:</h2>

      <ul>
      <!-- Posts Loop -->

      <?php query_posts( array( 'post_type' => 'iW_post', 'showposts' => 5, 'author='.$author->ID ) ); while (have_posts()) : the_post(); ?>

      <li><? echo $curauth->id;?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a></li>

      <?php endwhile; ?>

      <!-- /Posts Loop -->
      </ul>

      <?php } ?>

    • 07/27/10 12:24pm

      Aneesh Joseph says:

      <?php query_posts( array( 'post_type' => 'iW_post', 'showposts' => 5, 'author'=>$author->ID ) ); while (have_posts()) : the_post(); ?>


      :)

    • 07/27/10 12:31pm

      Adam Bundy says:

      Hey Aneesh- that's identical to what I have (see above source). Its working to echo posts, but the posts loop is not resetting for each author- I see same 5 posts for each author. Thanks!

    • 07/27/10 12:37pm

      Adam Bundy says:

      Hold up, found the difference. Thanks Aneesh. Testing now...

    • 07/27/10 12:40pm

      Adam Bundy says:

      Awesome Aneesh- that worked. How difficult would it be to modify the author query below to include only authors who have at least one iW_post?

      <?php $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");

    • 07/27/10 1:41pm

      Aneesh Joseph says:


      $authors = $wpdb->get_results("SELECT ID
      FROM $wpdb->users
      WHERE EXISTS
      (SELECT post_author
      FROM $wpdb->posts
      WHERE $wpdb->users.ID = $wpdb->posts.post_author
      AND $wpdb->posts.post_status = 'publish'
      AND $wpdb->posts.post_type = 'iW_post')
      ORDER BY display_name");

    • 07/27/10 1:48pm

      Adam Bundy says:

      Rock n' Roll! Thanks Aneesh!

This question has expired.





Current status of this question: Completed