Search

Table of Contents

Add the Author Details to the Authors Page

You are here:

In WordPress, and the PublishPress Authors plugin, every author has their own URL. This page lists all the content they have written.

By default, these author pages do not contain much information. This image is an example using the TwentyTwenty theme. It shows only the author's name.

Twenty Twenty Author
Twenty Twenty Author

It is possible to add the PublishPress Authors box to this page so that you can show more details about the author.


Option #1. Use a Theme With PublishPress Authors Support

Some themes do automatically support PublishPress Authors. For example, the popular Astra theme will automatically find and display your author's name, description and avatar:

Publishpress Authors Astra
Publishpress Authors Astra

Option #2. Add PHP to your theme

One option is to place this code directly into the template file for your WordPress theme. As with all WordPress development, we do recommend using a child theme if you want to modify the code.

This code uses PHP to display a shortcode and this guide explains how to customize the shortcode.

<?php echo do_shortcode( '[author_box layout="boxed" archive=1]' ); ?>

This code should be placed in the Archives section of the themes layout. For example, in the TwentyTwenty theme, you can place it directly under this code at line 65 of the index.php file:

	<?php if ( $archive_title ) { ?>
	<h1 class="archive-title"><?php echo wp_kses_post( $archive_title ); ?></h1>	
	<?php } ?>

If you want more control you can use the function get_multiple_authors to get an array of authors for the current post or post specified by the post ID.

Check the API provided by the Authors plugin for more details.

Here is an example of how you can iterate over the authors list passing the post ID:

<?php

$authors = get_multiple_authors($post_id);
$first_author = true;

echo '<ul>';

foreach ($authors as $author) {
    echo '<li>';
    
    if (!$first_author) {
        echo ', ';
    }

    echo sprintf(
        '<a href="%s">%s %s</a>',
        $author->link,
        $author->get_avatar(),
        $author->display_name
    ); 

    echo '</li>';

    $first_author = false;
}

echo '</ul>';

The get_multiple_authors function can be used to return the current user on the author's page setting the third param as true and the first as 0:

<?php

$authors = get_multiple_authors(0, true, true);

echo $authors[0]->display_name;

Option #3. Use a shortcode

This option can be used if you have a theme or pagebuilder that allows you to customize the Authors pages.

For example, the Elementor Pro plugin has a “Single & Archive Builder” that allows you to control the author pages. Another example, is the Beaver Builder that allows you to modify author pages with the Beaver Themer add-on.

If you have this option on your site, you can use this shortcode to show the author profile. This guide explains how to customize the shortcode.

[author_box layout="boxed" archive=1]

If your pagebuilder or theme doesn't have a way to display shortcodes, they probably will accept the “Widget Shortcode” plugin.


Professional publishing plugins for WordPress! Get PublishPress