Authors Data Shortcode

One of the shortcodes available in PublishPress Authors is the Authors Data shortcode.

The “Authors Data” shortcode is a more flexible alternative to the Author Box shortcode. With this shortcode you can show specific data from the authors attached to the post being viewed.

This is the basic version of the shortcode:


Here is how this shortcode appears when added to the Gutenberg editor in a block:

Authors Data Gutenberg
Authors Data Gutenberg

The simplest version of the shortcode will only show the Authors names. The power of this shortcodes in the extra parameters.

You can find examples of the Authors Data shortcodes by going to “Authors”, then “Settings”, then “Shortcodes” in your WordPress site.

Shortcodes Data
Shortcodes Data

Here are some examples of data elements that you can show:

  • display_name
  • first_name
  • last_name
  • ID
  • user_nicename
  • user_email

Let's see some examples. This shortcode will show only the first name of each author attached to the post:

[publishpress_authors_data field="first_name"]

This shortcode will show only the first name of each author, but separated with an asterisk:

[publishpress_authors_data field="last_name" seperator="*"]

This shortcode will show only the WordPress nicename of each author, only from the post with an ID of 32.

[publishpress_authors_data field="user_nicename" post_id="32"]

How far does this go? You can use almost any user field provided by WordPress. This documentation has more details. Some more examples include these:

  • user_login
  • user_email
  • user_url
  • user_registered
  • user_status
  • user_description

This shortcode is also useful for writing code to expand the PublishPress Authors plugin.

A good usage example is below. This will display all authors meta in the <head> code of your site:

<?php $authors_name = explode(",", do_shortcode('[publishpress_authors_data]')); ?>

<?php foreach ($authors_name as $author_name) : ?>

<metaproperty="article:author" content="<?php esc_attr_e($author_name);"/>

<?php endforeach; ?>

There is one final option to mention. This is mostly useful if you're using a theme or page builder to customize the Author profile pages you find at URLs such as /author/username/. You can use the following shortcode on the authors page to display the profile of the current author. You just need to add the parameter archive="true":

[publishpress_authors_data archive="true"]

Professional publishing plugins for WordPress! Get PublishPress