Byline Template Tags

Molongui » Help » Molongui Authorship Docs » Byline » Byline Template Tags

Guest posting and co-authoring are two features that WordPress doesn’t provide. And that’s where Molongui Authorship comes in handy :)

You reading this article might mean two things: A) You are a theme or plugin developer that want to make your masterpiece fully compatible with Molongui Authorship. B) You are a user experiencing issues with your bylines. In either case, keep reading.

Bylines are a capital point when talking about guest posting and co-authoring. They need to display the correct author name, no matter whether it is a regular post, a guest post or a multi-authored post. Molongui Authorship hooks into WordPress core to achieve just that, but, let’s face it, sometimes it fails. There are many things going on your site (WP, theme, plugins…), from many different developers, so conflicts happen. But wait! Keep reading! It failing doesn’t mean you have to give up on our plugin.

If you are already experiencing byline issues, please open a support ticket with us so we can look into it to provide a fix. Most probably there might be some sort of conflict with your theme. Thanks to other users we have already been able to make the plugin compatible with many themes and plugins.

If you just want to make your code fully compatible with Molongui Authorship, we provide some useful template tags you can use.

Displaying fully customized and functional bylines can be achieved using the provided template tags. It requires some basic coding skills, but using template tags is the best way to go in order to avoid issues with other plugins. Some parameters can be provided to the template tags so bylines can be fully localized and customized with custom HTML code and CSS styles.

Available Template Tags

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

Molongui Authorship provides similar template tags useful to display guest and multi-author bylines. They can be found into the template-tags.php file. The most relevant are:

				
					/**
 * Outputs the authors display names, without links to their archive pages.
 * This tag must be used within 'The Loop'.
 * This function is the one to use as replacement for 'the_author()' template tag.
 *
 * @param   int     $pid            Post id. Defaults to null.
 * @param   string  $separator      Delimiter that should appear between the authors.
 * @param   string  $last_separator Delimiter that should appear between the last two authors.
 * @param   string  $before         String to be prepended before the author name(s). Defaults to an empty string.
 * @param   string  $after          String to be appended after the author name(s). Defaults to an empty string.
 * @return  void                    Displays the byline.
 */
function the_molongui_author( $pid = null, $separator = ', ', $last_separator = '', $before = '', $after = '' )
{
   echo get_the_molongui_author( $pid, $separator, $last_separator, $before, $after );
}

/**
 * Outputs the authors display names, with links to their archive pages.
 * This tag must be used within 'The Loop'.
 * This function is the one to use as replacement for 'the_author_posts_link()' template tag.
 *
 * @param   int     $pid            Post id. Defaults to null.
 * @param   string  $separator      Delimiter that should appear between the authors.
 * @param   string  $last_separator Delimiter that should appear between the last two authors.
 * @param   string  $before         String to be prepended before the author name(s). Defaults to an empty string.
 * @param   string  $after          String to be appended after the author name(s). Defaults to an empty string.
 * @return  void                    Displays the byline with linked names.
 */
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 );
}
				
			

First template tag displays just the author names(s). The second, the author name(s) as a link each author archive page.

Check out this support article to get some examples on how to integrate these template tags in your theme.

Updated on February 22, 2022

Did not find a solution? We are here to help you succeed.
Open a support ticket