Molongui Authorship

  1. Molongui
  2. >
  3. Docs
  4. >
  5. Molongui Authorship
  6. >
  7. Howto
  8. >
  9. How to incorporate Molongui Authorship template tags into your theme

How to incorporate Molongui Authorship template tags into your theme

This article applies to any version of the plugin, release 2.0.0 or higher.


Molongui Authorship makes it easy to assign one or more bylines to a post. Upon activation, you’ll be able to start assigning multiple bylines right away. In order for those bylines to appear on the frontend, you may need to make some small modifications to your theme.

Available Template Tags

WordPress offers template tags like the_author() and the_author_posts_link() to display byline information associated with each post post. You might see these inside files like single.php and author.php.

Molongui Authorship has similar template tags for displaying multiple bylines. These are located in the template-tags.php file. The most relevant are:

function the_molongui_author( $pid = null, $separator = ', ', $last_separator = '', $before = '', $after = '' )
   echo get_the_molongui_author( $pid, $separator, $last_separator, $before, $after );

function the_molongui_author_posts_link( $pid = null, $separator = ', ', $last_separator = '', $before = '', $after = '' )
   echo get_the_molongui_author_posts_link( $pid, $separator, $last_separator, $before, $after );

Each of these template tags will present different aspects of the multiple bylines. For instance, the first will display the first and last name of each author without any links. The second will display the first and last name of author linking back to their author profile page. And so on.

Integrating Template Tags Into Your Theme

To integrate Molongui Authorship, you’ll want to replace existing author template tags in your theme with a simple conditional that uses the Molongui Authorship template tags if Molongui Authorship is available. The conditional prevents your site from breaking (e.g. white screen of death) if Molongui Authorship isn’t activated.

For example, here’s how you would update the_author_posts_link() to instead use the_molongui_author_posts_links():

if ( function_exists( 'the_molongui_author_posts_link' ) ){
} else {

However, the example above is a relatively simplistic way of presenting bylines. There’s a good chance your theme will need an adaptation of it. Below we explain how to integrate Molongui Authorship template tags in some of the most used themes:

Twenty Seventeen

Here’s how the change looks for TwentySeventeen theme:

if ( ! function_exists( 'twentyseventeen_posted_on' ) ) :
 * Prints HTML with meta information for the current post-date/time and author. Supports Molongui Authorship plugin.
function twentyseventeen_posted_on()
   // Integrate Molongui Authorship with TwentySeventeen by replacing twentyseventeen_posted_on() with this function
   if ( function_exists( 'get_the_molongui_author_posts_link' ) )
      $byline = get_the_molongui_author_posts_link();
      // Get the author name; wrap it in a link.
      $byline = sprintf(
         _x( 'by %s', 'post author', 'twentyseventeen' ),
        '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . get_the_author() . '</a></span>' );

   // Finally, let's write all of this to the page.
   echo '<span class="posted-on">' . twentyseventeen_time_link() . '</span><span class="byline"> ' . $byline . '</span>';


GeneratePress theme has a very useful filter for us, so you just should include the code below on your “functions.php” file of your child theme:

 * Molongui Authorship
 * Use theme's filter to customize byline with Molongui Authorship template tags.
 * @see 'inc/structure/post-meta.php' file
if ( function_exists( 'the_molongui_author_posts_link' ) )
   add_filter( 'generate_post_author_output', function()
Was this article helpful to you? Yes No 1

How can we help?