• 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

How do I make a custom loop on author.php?

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 › How do I make a custom loop on author.php?

This topic is: not resolved

Tagged: author page

  • This topic has 6 replies, 3 voices, and was last updated 9 years, 3 months ago by carasmo.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • February 22, 2016 at 4:11 pm #179654
    songdogtech
    Participant

    How do I make an author.php page template with a custom loop?

    I want to simply list all post title and dates, and not excerpts, author bio boxes or anything else. So I need to unhook the Genesis loop and run my own loop on author.php. But I've tried that with the page template below, and I end up with broken HTML5.

    I'm using this in author.php right now:

    <?php
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'author_loop' );
    
    function author_loop() {
    
    // my loop to list all post titles and dates
    
    wp_reset_query();
    }
    
    genesis();

    But that doesn't give me the HTML5 output of a normal page, like this:

    <div class="site-inner">
    <div class="content-sidebar-wrap">
    <main class="content" id="genesis-content">
    <article class="post-557 page type-page status-closed entry articles" itemscope itemtype="http://schema.org/CreativeWork">
    <header class="entry-header">
    <h1 class="entry-title" itemprop="headline">Page Title</h1> 
    </header>
    <div class="entry-content" itemprop="text">
    (post excerpts

    What I get is broken HTML5, missing the article and header divs, like this:

    <div class="site-inner">
    <div class="content-sidebar-wrap">
    <main class="content" id="genesis-content">
    <div class="archive-description author-archive-description author-description">
    <h1 class="archive-title">Archive Title</h1>
    </div>
    (the text of my author loop)

    The sidebars are in place, so the full Genesis loop is running. I just want to replace the default author.php loop with my own.

    Any ideas?

    February 22, 2016 at 5:03 pm #179657
    carasmo
    Participant

    I just tested a custom loop with Bill's code (https://gist.github.com/billerickson/3218052) and all the structural markup (site-inner etc, is there and the page has no broken html)

    <?php
    
    /**
     * Template Name: Author Page
     */
     
    function themeprefix_author_loop() {
    
       global $post;
    	// arguments, adjust as needed
    	$args = array(
    		'post_type'      => 'post',
    		'posts_per_page' => 1,
    		'post_status'    => 'publish',
    		'paged'          => get_query_var( 'paged' )
    	);
    	/* 
    	Overwrite $wp_query with our new query.
    	The only reason we're doing this is so the pagination functions work,
    	since they use $wp_query. If pagination wasn't an issue, 
    	use: https://gist.github.com/3218106
    	*/
    	global $wp_query;
    	$wp_query = new WP_Query( $args );
    	if ( have_posts() ) : 
    		echo '<ul>';
    		while ( have_posts() ) : the_post(); 
    			echo '<li>' . get_the_title() . '</li>';
    		endwhile;
    		echo '</ul>';
    		do_action( 'genesis_after_endwhile' );
    	endif;
    	wp_reset_query();
    
    }
    
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'themeprefix_author_loop' );
        
    genesis();

    Genesis Theme Customization and Help

    February 22, 2016 at 8:45 pm #179679
    songdogtech
    Participant

    Thanks, but I tried that already, and that page template is functionally no different than mine. The key here is that my file is named author.php, the default name for the author template in WordPress, and Genesis themes don't have an author.php file, as far as I have seen, while many other WP themes do. This is with the Genesis Sample theme.

    February 23, 2016 at 5:07 am #179699
    carasmo
    Participant

    Mine is a custom child theme from scratch and all of the structural markup is there. Using Bill's code on a page named author.php, I have put a class on the loop to make it easier to see and here's the parsed html:

    I used the exact code from Bill's gist.

             <div class="site-inner">
                <div class="content-sidebar-wrap">
                   <main class="content" id="genesis-content">
                      <div class="archive-description author-archive-description author-description">
                         <h1 class="archive-title">Christina</h1>
                      </div>
                      <ul class="author-posts">
                         <li>Sample Post With Threaded Comments</li>
                         <li>Sample Post With Image Centered</li>
                         <li>Sample Post With an Ordered List</li>
                         <li>Sample Post With a Blockquote</li>
                         <li>Sample Post With a Table</li>
                         <li>Sample Post With Headlines</li>
                         <li>Sample Post With Image Aligned Right</li>
                      </ul>
                   </main>
                </div>
             </div>
             <footer class="site-footer" itemscope itemtype="http://schema.org/WPFooter">
                <div class="wrap">
                   ...
                </div>
             </footer>
          </div> <!-- ends .site-container -->
    

    Genesis Theme Customization and Help

    February 23, 2016 at 7:01 am #179707
    carasmo
    Participant

    I looked in loops.php in Genesis and this works like a charm, including the regular markup that goes on each post itself.

    https://gist.github.com/carasmo/ff6e0d9687a7addfe8bd -- for author.php -- shows only the titles as h2 tags but I added a filter to turn them into h3 tags
    https://gist.github.com/carasmo/70a4fd9cc27d5822e03a -- for functions.php file if you want to add pagination to any archive type besides the blog/index it goes in your functions and you don't need to do anything in the author.php file.


    Genesis Theme Customization and Help

    February 23, 2016 at 7:54 am #179711
    Genesis Developer
    Member

    You will always use the genesis_custom_loop() function. Otherwise you can get lot of issue. You can try this once

    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'author_loop' );
    
    function author_loop() {
      $args = array(); // write custom query args in this array
    
      // now pass this $args variable in genesis_custom_loop function like this 
      genesis_custom_loop( $args );
    }
    
    genesis();

    Now you will use add_action or remove_action for any custom content for your author. Hope it helps.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    February 23, 2016 at 8:23 am #179712
    carasmo
    Participant

    I just tested my gist https://gist.github.com/carasmo/ff6e0d9687a7addfe8bd extensively with debug on. There is no need for genesis_custom_loop... in this case of making a template author.php.


    Genesis Theme Customization and Help

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘General Discussion’ is closed to new topics and 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