Linkify Authors

Author:Scott Reilly
Version:1.1
Last update:06 Jan 2010
Compatibility:WP 2.8+, 2.9+
Comments:go here
Download:[ zip ]
Description:

Turn a string, list, or array of author IDs and/or slugs into a list of links to those authors.

Extended Description

Turn a string, list, or array of author IDs and/or slugs into a list of links to those authors.

These are all valid calls:

<?php linkify_authors(3); ?>
<?php linkify_authors("3"); ?>
<?php linkify_authors("scott"); ?>
<?php linkify_authors("3 9 10"); ?>
<?php linkify_authors("scott bill alice"); ?>
<?php linkify_authors("scott 9 alice"); ?>
<?php linkify_authors("3,9,10"); ?>
<?php linkify_authors("scott,bill,alice"); ?>
<?php linkify_authors("scott,92,alice"); ?>
<?php linkify_authors("3, 9, 10"); ?>
<?php linkify_authors("scott, bill, alice"); ?>
<?php linkify_authors("scott, 92, alice"); ?>
<?php linkify_authors(array(43,92,102)); ?>
<?php linkify_authors(array("43","92","102")); ?>
<?php linkify_authors(array("scott","bill","alice")); ?>
<?php linkify_authors(array("scott",92,"alice")); ?>

<?php linkify_authors("3 9"); ?>
Displays something like:
<a href="http://yourblog.com/archives/author/admin">Scott</a>, <a href="http://yourblog.com/archives/author/billm">Bill</a>

<ul><?php linkify_authors("3, 9", "<li>", "</li>", "</li><li>"); ?></ul>
Displays something like:

<ul><li><a href="http://yourblog.com/archives/author/admin">Scott</a></li>
<li><a href="http://yourblog.com/archives/author/billm">Bill</a></li></ul>

<?php linkify_authors(""); // Assume you passed an empty string as the first value ?>
Displays nothing.

<?php linkify_authors("", "", "", "", "", "No related authors."); // Assume you passed an empty string as the first value ?>
Displays:
No related authors.

Find out more at the plugin’s WordPress Plugin Repository page.


Installation

  1. Unzip linkify-authors.zip inside the /wp-content/plugins/ directory for your site (or install via the built-in WordPress plugin installer)
  2. Activate the plugin through the ‘Plugins’ admin menu in WordPress
  3. Use the linkify_authors() template author in one of your templates (be sure to pass it at least the first argument indicating what author IDs and/or slugs to linkify — the argument can be an array, a space-separate list, or a comma-separated list). Other optional arguments are available to customize the output.

Template Tag

This plugin provides 1 template tag(s).

Function

linkify_authors($authors, $before = '', $after = '', $between = ', ', $before_last = '', $none = '')

Displays links to each of any number of authors specified via author IDs and/or slugs

Arguments

  • $authors : A single author ID/slug, or multiple author IDs/slugs defined via an array, or multiple author IDs/slugs defined via a comma-separated and/or space-separated string
  • $before : (optional) To appear before the entire author listing (if authors exist or if ‘none’ setting is specified)
  • $after : (optional) To appear after the entire author listing (if authors exist or if ‘none’ setting is specified)
  • $between : (optional) To appear between all authors
  • $before_last : (optional) To appear between the second-to-last and last element, if not specified, ‘between’ value is used
  • $none : (optional) To appear when no authors have been found. If blank, then the entire function doesn’t display anything

Release Log


Copyright & Disclaimer

Copyright © 2009-2010 by Scott Reilly (aka coffee2code)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.