• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Author's Posts Loop in author.php page

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Author's Posts Loop in author.php page

This topic is: resolved

Tagged: author.php, authors, loop

  • This topic has 3 replies, 2 voices, and was last updated 9 years ago by lomaymi.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • April 27, 2016 at 11:16 am #184534
    lomaymi
    Member

    I'm making a custom author.php page with the following format:

    1. Custom profile pic (no gravatar)
    2. Author Name
    3. Author social networks
    4. Author biographical information
    5. Archive headline and description text
    6. Author blog post loop

    I managed to make everything from 1 to 5 exactly the way I wanted, but I can't figure out how to call author posts loop. I want to be able to have full control of the position of blog post titles, featured images, excerpt, etc. Here what I have so far on my author.php:

    
    <?php
    
    get_header();
    
    //* Variable to call current author of page
    $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
    ?>
    
    <!-- Author Profile Picture from custom profile picture url-->
    
    <div class="authorpage_pic">
    
    <?php if ( get_the_author_meta( 'avatar' ) != '' ): ?><img src="<?php echo get_the_author_meta( 'avatar' ); ?>"><?php endif; ?>
    
    </div>
    
    <!-- Author first and last names-->
    
    <h2 align="center" ><?php echo $curauth->first_name; ?> <?php echo $curauth->last_name; ?></h2>
    
    <!-- Author social media accounts-->
    
    <div class="authorpage_social">
    
    <ul class="social-icons">
    	                
         <?php if ( get_the_author_meta( 'facebook' ) != '' ): ?>
            <li><a href="<?php echo get_the_author_meta( 'facebook' ); ?>" target="_blank"><i class="fa fa-facebook"></i></a></li>
        <?php endif; ?>
        
        <?php if ( get_the_author_meta( 'twitter' ) != '' ): ?>
            <li><a href="https://twitter.com/<?php echo get_the_author_meta( 'twitter' ); ?>" target="_blank"><i class="fa fa-twitter"></i></a></li>
        <?php endif; ?>
        
         <?php if ( get_the_author_meta( 'linkedin' ) != '' ): ?>
            <li><a href="<?php echo get_the_author_meta( 'linkedin' ); ?>" target="_blank"><i class="fa fa-linkedin"></i></a></li>
        <?php endif; ?>
        
        <?php if ( get_the_author_meta( 'googleplus' ) != '' ): ?>
            <li><a href="<?php echo get_the_author_meta( 'googleplus' ); ?>" target="_blank"><i class="fa fa-google-plus"></i></a></li>
        <?php endif; ?>
    
         <?php if ( get_the_author_meta( 'instagram' ) != '' ): ?>
            <li><a href="<?php echo get_the_author_meta( 'instagram' ); ?>" target="_blank"><i class="fa fa-instagram"></i></a></li>
        <?php endif; ?>
        
         <?php if ( get_the_author_meta( 'youtube' ) != '' ): ?>
            <li><a href="<?php echo get_the_author_meta( 'youtube' ); ?>" target="_blank"><i class="fa fa-youtube-play"></i></a></li>
        <?php endif; ?>
        
        <?php if ( get_the_author_meta( 'user_email' ) != '' ): ?>
            <li><a href="mailto:<?php echo get_the_author_meta( 'user_email' ); ?>" target="_blank"><i class="fa fa-envelope"></i></a></li>
        <?php endif; ?>
        
        <?php  if ( get_the_author_meta( 'user_url' ) != '' ): ?>
            <li><a href="<?php echo get_the_author_meta( 'user_url' ); ?>" target="_blank"><i class="fa fa-desktop"></i> </a></li>
        <?php endif; ?>
        
        </ul>
    </div>
    
    <!-- Author biographical info-->
    
    <p><?php echo $curauth->description; ?></p>
    
    <!-- Author archive headline and description text-->
    
    <?php
    
    if ( ! is_author() )
    		return;
    
    	$headline = get_the_author_meta( 'headline', (int) get_query_var( 'author' ) );
    
    	$intro_text = get_the_author_meta( 'intro_text', (int) get_query_var( 'author' ) );
    
    	$headline   = $headline ? sprintf( '<h1 %s>%s</h1>', genesis_attr( 'archive-title' ), strip_tags( $headline ) ) : '';
    	$intro_text = $intro_text ? apply_filters( 'genesis_author_intro_text_output', $intro_text ) : '';
    
    	if ( $headline || $intro_text )
    		printf( '<div %s>%s</div>', genesis_attr( 'author-archive-description' ), $headline . $intro_text );
    		
    // Author blog post loop 
    
    get_footer(); 
    
    ?>
    
    

    Any suggestions to achieve what I want will be greatly appreciated.

    April 27, 2016 at 11:39 am #184536
    Victor Font
    Moderator

    Take a look at the source code for the WordPress wp_list_authors function and see how they do it. Perhaps it will provide some ideas: https://developer.wordpress.org/reference/functions/wp_list_authors/


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    April 28, 2016 at 12:36 am #184583
    lomaymi
    Member

    Just figure it out after many hours of trial and error. Will post my code here so anyone can use as reference:

    
    <!-- AUTHOR BLOG POST LOOP 2 COLUMNS -->
    
    <h2>Post by <?php echo $curauth->first_name; ?></h2>
    <br>
    
    <!-- Set parameters to display in posts loops-->
    
    <?php 
    
    $args1 = array( 
    	'numberposts' => 2, 
    	'offset' => 0,  
    	'author' => $authordata->ID,
    	'post_not_in' => array( $post->ID )
    	);
    	
    	
    $args2 = array( 
    	'numberposts' => 2, 
    	'offset' => 2,  
    	'author' => $authordata->ID,
    	'post_not_in' => array( $post->ID )
    	);	
    	
    // This is for author remaining blog posts 
    $args3 = array( 
    	'offset' => 4,  
    	'author' => $authordata->ID,
    	'post_not_in' => array( $post->ID )
    	);	
    
    ?> 
    
    <div class="author_columns">
    
    <!-- First column loop posts -->
    
    <div class="one-half first">
    
    <?php query_posts('showposts=2'); ?>
    <?php $posts = get_posts($args1); foreach ($posts as $post) : start_wp(); ?>
    <?php static $count1 = 0; if ($count1 == "2") { break; } else { ?>
    
    <a href="<?php the_permalink() ?>"><?php the_post_thumbnail('medium'); ?> </a>
    <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php the_excerpt (); ?>
    
    <?php $count1++; } ?>
    <?php endforeach; ?>
    
    </div>
    
    <!--Second column loop posts offset 2-->
    
    <div class="one-half">
    
    <?php query_posts('showposts=2'); ?>
    <?php $posts = get_posts($args2); foreach ($posts as $post) : start_wp(); ?>
    <?php static $count2 = 0; if ($count2 == "2") { break; } else { ?>
    
    <a href="<?php the_permalink() ?>"><?php the_post_thumbnail('medium'); ?> </a>
    <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php the_excerpt (); ?>
    
    <?php $count2++; } ?>
    
    <?php endforeach; ?>
    
    </div>
    
    </div>
    
    <!--AUTHOR REMAINING BLOG POST LIST AFTER FOURTH ENTRY -->
    
    <ul class="author_post_list">
    <?php
    
    $myposts = get_posts( $args3 );
    foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
    
    	<li><h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4></li>
        
    <?php endforeach; 
    wp_reset_postdata();?>
    
    </ul>
    

    Here are a couple of resources I found very useful (couldn’t post hyperlinks, it appears this marks message as spam. Just do a Google search):

    • Code Reference: the_excerpt()
    • <Codex: Post Thumbnails
    • Codex: Template Tags/get posts
    • How to Display Related Posts by Same Author in WordPress
    • get_posts - get all posts by author id
    • 6 Ways to Display WordPress Post Content in Multiple Columns

    If you got any questions about my code feel free to reply.

    May 8, 2016 at 10:19 am #184582
    lomaymi
    Member

    Just figure it out after many hours of trial and error. Will post my code here so anyone can use as reference:

       
    &lt;!-- AUTHOR BLOG POST LOOP 2 COLUMNS --&gt;
    
    &lt;h2&gt;Post by &lt;?php echo $curauth-&gt;first_name; ?&gt;&lt;/h2&gt;
    &lt;br&gt;
    
    &lt;!-- Set parameters to display in posts loops--&gt;
    
    &lt;?php 
    
    $args1 = array( 
    	'numberposts' =&gt; 2, 
    	'offset' =&gt; 0,  
    	'author' =&gt; $authordata-&gt;ID,
    	'post_not_in' =&gt; array( $post-&gt;ID )
    	);
    	
    	
    $args2 = array( 
    	'numberposts' =&gt; 2, 
    	'offset' =&gt; 2,  
    	'author' =&gt; $authordata-&gt;ID,
    	'post_not_in' =&gt; array( $post-&gt;ID )
    	);	
    	
    // This is for author remaining blog posts 
    $args3 = array( 
    	'offset' =&gt; 4,  
    	'author' =&gt; $authordata-&gt;ID,
    	'post_not_in' =&gt; array( $post-&gt;ID )
    	);	
    
    ?&gt; 
    
    &lt;div class="author_columns"&gt;
    
    &lt;!-- First column loop posts --&gt;
    
    &lt;div class="one-half first"&gt;
    
    &lt;?php query_posts('showposts=2'); ?&gt;
    &lt;?php $posts = get_posts($args1); foreach ($posts as $post) : start_wp(); ?&gt;
    &lt;?php static $count1 = 0; if ($count1 == "2") { break; } else { ?&gt;
    
    <a>"&gt;&lt;?php the_post_thumbnail('medium'); ?&gt; </a>
    &lt;h3&gt;<a>" title="&lt;?php the_title(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;</a>&lt;/h3&gt;
    &lt;?php the_excerpt (); ?&gt;
    
    
    &lt;?php $count1++; } ?&gt;
    &lt;?php endforeach; ?&gt;
    
    &lt;/div&gt;
    
    &lt;!--Second column loop posts offset 2--&gt;
    
    &lt;div class="one-half"&gt;
    
    &lt;?php query_posts('showposts=2'); ?&gt;
    &lt;?php $posts = get_posts($args2); foreach ($posts as $post) : start_wp(); ?&gt;
    &lt;?php static $count2 = 0; if ($count2 == "2") { break; } else { ?&gt;
    
    
    <a>"&gt;&lt;?php the_post_thumbnail('medium'); ?&gt; </a>
    &lt;h3&gt;<a>" title="&lt;?php the_title(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;</a>&lt;/h3&gt;
    &lt;?php the_excerpt (); ?&gt;
    
    &lt;?php $count2++; } ?&gt;
    
    &lt;?php endforeach; ?&gt;
    
    &lt;/div&gt;
    
    &lt;/div&gt;
    
    &lt;!--AUTHOR REMAINING BLOG POST LIST AFTER FOURTH ENTRY --&gt;
    
    &lt;ul class="author_post_list"&gt;
    &lt;?php
    
    $myposts = get_posts( $args3 );
    foreach ( $myposts as $post ) : setup_postdata( $post ); ?&gt;
    
    	<li>&lt;h4&gt;<a>"&gt;&lt;?php the_title(); ?&gt;</a>&lt;/h4&gt;</li>
        
    &lt;?php endforeach; 
    wp_reset_postdata();?&gt;
    
    </ul>
    
    

    Here are a couple of resources I found very useful:

    • Code Reference: the_excerpt()
    • Codex: Post Thumbnails
    • Codex: Template Tags/get posts
    • How to Display Related Posts by Same Author in WordPress
    • get_posts - get all posts by author id
    • 6 Ways to Display WordPress Post Content in Multiple Columns

    If you got any questions about my code feel free to reply.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Author's Posts Loop in author.php page’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble