Using custom template for authors index

I have been able to create custom templates for both the /blog index and the blog pages – working great!

I am also trying to create a custom template for the authors indexes (ie. https:///author/<author_username>/) but not finding any references to this. I did find references to potentially modifying individual author pages (based on https://theme.co/apex/forums/topic/archive-integrity-page-customize/#post-233376, where I assume I could create a file such as ), I am assuming I could create a file such as taxonomy-author-authname.php in the child theme root. However, I am trying to create a custom template that will be used for all author indexes, rather than per author.

How is this accomplished?

Hello There,

Thanks for posting in!

Please refer to the WordPress template hierarchy:

These are the author files that needs to be created and added in your child theme.

Hope this helps.

I should have been more explicit – I am aware of the Wordpress native template hierarchy and have used this in the past, sans X/Pro.

However, placement of these specified files, such as author.php that work fine in other Wordpress environments, are not working in an X/Pro environment. Since I had recently run into other X/Pro specific template nuances, I assumed the same was true here. Either way, the author template files specified in https://developer.wordpress.org/themes/basics/template-hierarchy/ are not working in our X Environment.

Please advise.

Hello There,

Could you please post the contents of your author.php file so that I could check the code and test it in my local testing server? You can post the whole code in your next reply.

Thank you in advance.

Example below (working on other, nonX instances when placed in the child-theme root dir. For X, it just produces a blank page:

<?php
/* Template Name: Custom Author Index*/
get_header(); ?>

<div class="clear"></div>
</header>

<div id="content" class="site-content">

<div class="container">

  <div class="content-left-wrap col-md-9">
    <div id="primary" class="content-area">
      <main id="main" class="site-main" role="main">

        <?php while ( have_posts() ) : the_post(); ?>

          <?php get_template_part( 'content', 'page' );  ?>

        <?php endwhile; ?>

      </main>
    </div>
  </div>
  <div class="sidebar-wrap col-md-3 content-left-wrap">
    <?php get_sidebar(); ?>
  </div>

</div>

<?php get_footer(); ?>

Hi,

You can try this code instead.

<?php get_header(); ?>
    <div class="x-container max width offset">
        <div class="<?php x_main_content_class(); ?>" role="main">
            <?php if ( have_posts() ) : ?>
                <?php while ( have_posts() ) : the_post(); ?>
                    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                        <div class="entry-wrap">  
                        <?php x_get_view( 'global', '_content', 'the-excerpt' ); ?>
                        </div>
                    </article>
                <?php endwhile; ?>
            <?php else : ?>
                <?php x_get_view( 'global', '_content-none' ); ?>
            <?php endif; ?>
        </div>
        <?php get_sidebar(); ?>
    </div>
<?php get_footer(); ?>

You may edit it as you wish.

Thanks

Thanks!

Tried placing this in the root of the X child theme, but all of the /author/authorname pages are blank (no header, footer or content) using this code, same as my example.

Also tried placing it in child-theme/frameworks/views/stack-in-use/* but it has no effect there (author index page reverts to the default).

Even if I change the author.php in the child theme root to:

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

I get a fully blank page. I also tried changing the filename to author-specificauthorname.php, and all of the other author pages (other than the username in the new filename) reverted to the default. The index for specificauthorname was fully blank.

Based on this, it is certainly picking up the existence of author.php for all authors, and author-authorname.php for the specific author correctly, but its not processing the contained php correctly. No errors are showing in (dev mode) browser console, Apache logs or WP debug logs. Just blank pages.

Hey There,

Would you mind providing us with login credentials so we can take a closer look? Please provide following information:

Set it as Secure Note

  • Link to your site
  • WordPress Admin username / password
  • FTP credentials

All the best!

This is currently a staging site, with all access requiring VPN setup for access for HTTP(s)/SSH/FTP.

Hi,

I have tested the code in one of my test site and it seems to work.

I created author.php in child theme’s root with the code I provided.

Can you create a zip file of your child theme and send us a link to it so we can test it in our installation.

Thanks

Zip archive of the child theme attached.

Hey There,

I have checked your child theme and the author-{authorname}.php template is working as intended to be. The only problem is that you have heavily modified the header.php and it is causing a fatal error. Let’s first resolve your author template file by removing or renaming header.php and footer.php files in your child theme. You should be able to see that your author template file is working. We will work out your header modification later on.

Please let is know how it goes.

This exact header and footer setup has worked fine on non-Pro WP instances – been in operation 12 months+ without change or issue – with author.php working as well. Are you suggesting something in header or footer is Pro incompatible? If so, please be specific.

Also, if you re-read my original request, I am not looking for author-specific templates, but to provide a single custom template that all author index pages will use.

Hello There,

Your header.php and footer.php file will not work with Pro theme because we have a different way of having these templates in Pro theme. That is why I suggested that you temporarily remove or rename these files so that you can test and see that the author.php file will work. Paul and I already tested the contents of the author.php file and it is working in our test sites. In your child theme, it is not working because of the Fatal Error that is coming from your header.php file. Please understand that the contents of the header.php and footer.php files in Pro theme is totally different with other themes. This is also why I mentioned that we will deal your header.php and footer.php file to work with Pro theme later on.

To test it out, please do this:

  • Rename your header.php file to old_header.php
  • Rename your footer.php file to old_footer.php
  • Make sure that you have the author.php file and your code in place.
  • Your author pages should display the post items with no errors.

Again, once you can confirm that the author page is correct, we will fully transform your codes in the header.php file so that it will work with Pro theme.

Thank you for your understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.