Authors Data Shortcode

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

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

This is the simplest 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; ?>

Professional publishing plugins for WordPress! Get PublishPress