WordPress.org

Ready to get started?Download WordPress

Forums

Authors page for custom post type (2 posts)

  1. adambundy
    Member
    Posted 4 years ago #

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

  2. mattkaner
    Member
    Posted 3 years ago #

    Hi there - I noticed you published a solution to this - although I've tried implementing it and it seems to cause problems with pagination for me.

    I've used the usual query_posts pagination fix and adapted your code like this:

    <?php
    $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 = 'blog')
    ORDER BY display_name");
    
    foreach($authors as $author) {
    	$curauth = get_userdata(intval($author->ID));
    ?>
    
    <h2>Author Profile for <span style="color:#560000;"><?php echo $curauth->first_name; ?> <?php echo $curauth->last_name; ?></span></h2>
    <p><?php echo $curauth->user_description; ?></p>
    <div style="height:8px;"></div>
    <h2 style="font-size:15pt;"><?php echo $curauth->first_name; ?>’s Posts</h2>
        <!-- Posts Loop -->
    <?php if (have_posts()) : ?>
         <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("post_type=any&paged=$paged&author=$author->ID&orderby=date&showposts=2"); while (have_posts()) : the_post(); ?>
    
    <div style="padding-left:20px; padding-right:20px;">
    <div id="smallerheaders"><h2><?php the_title(); ?></h2></div>
    <?php the_content(__('(Click for more...)')); ?></div>
    <div id="nextentry"></div>
    <?php endwhile; else: ?>
    <p><?php _e('No posts by this author.'); ?></p>
    <?php endif; ?>
    <?php } ?>
    
    <div class="clear"></div>
    <div style="width:400px; padding-left:20px; padding-bottom:20px; margin-top:1px; overflow:hidden; font-size:10pt; font-family:Georgia;"><?php wp_pagenavi(); ?></div>
    <?php wp_reset_query(); ?>
      </div>
      </div>
    
    <?php get_footer(); ?>

    But it still seems to cause me trouble (the second page and any after that just create a 404).

Topic Closed

This topic has been closed to new replies.

About this Topic