Add Author Boxes to Your Theme

The PublishPress Authors plugin allows you to show author profiles using this a snippet of PHP code. This code can be modified in many way to suit your needs.

Don't worry if you're not technical. There are also other ways to show your authors that require no code.

We recommend that you add these code snippets to a child theme, as that is best practice for WordPress theme development. We do have child themes available for some popular themes.

It is also possible to use the PublishPress Authors API to show external data.


The Basic Authors Code #

This is the most basic PHP code to load the Author Box for a post. This will show the default “Boxed” layout.

<?php do_action( 'pp_multiple_authors_show_author_box' ); ?>

Expanding the Code: Title #

You can modify this basic code in several ways. The first argument you can can add to the code will control the title.

Here is one example with the first argument set to false. In this code, false will hide the title of the authors area. If you change this to true, the title for the area will appear.

<?php do_action('pp_multiple_authors_show_author_box', false); ?>

Expanding the Code: Layout #

The second argument you can add to this code will control the layout. Here is an example using the layout with an ID of “ppma_boxes_117”:

<?php do_action('pp_multiple_authors_show_author_box', false, 'ppma_boxes_117'); ?>

Expanding the Code: Author Pages #

The third argument allows you to use this code on the author pages of your site. These are the individual author pages you see at URLs like this:

  • example.com/authors/john-doe
  • example.com/authors/jane-doe

The true in the third argument of this code will force it to detect the author from the current URL, instead of from the current post. This means it can be used to display the author's information on the page header, for the current author.

<?php do_action('pp_multiple_authors_show_author_box', false, 'ppma_boxes_117', true); ?>

For the posts loop in the author page, you have to keep the false in the third argument and follow the instructions below (for archive pages) so it will display the authors of the current post in the loop.


Expanding the Code: Archive Pages #

By default, the basic code shown at the top of this guide will only display the author box for a single post page.

The fourth argument allows you to use this code in the posts loop on archive/author pages or on the homepage of your site. The true in the fourth argument of this code will force it to run whenever used, not just inside a single post loop. It is important to also keep the third argument as false in this case.

<?php do_action('pp_multiple_authors_show_author_box', false, 'ppma_boxes_117', false, true); ?>