Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jeremyboggs
Created July 31, 2012 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jeremyboggs/3219048 to your computer and use it in GitHub Desktop.
Save jeremyboggs/3219048 to your computer and use it in GitHub Desktop.
Function to filter item_citation to account for multiple creators.
<?php
/**
* Function to filter item_citation to account for multiple creators.
*/
function item_citation_multiple_creators($cite, $item) {
$cite = '';
if ($creators = item('Dublin Core', 'Creator', array('all' => true), $item)) {
switch(count($creators)) {
case 1:
$cite .= $creators[0];
break;
case 2:
$cite .= implode(' and ', $creators);
break;
case 3:
$cite .= $creators[0] . ', ' . $creators[1] . ', and ' . $creators[2];
break;
default:
$cite .= $creators[0] . ' et. al.';
break;
}
$cite = $cite . ', ';
}
if ($title = item('Dublin Core', 'Title', array(), $item)) {
$cite .= "&#8220;$title,&#8221; ";
}
if ($siteTitle = settings('site_title')) {
$cite .= "<em>$siteTitle</em>, ";
}
$cite .= "accessed " . date('F j, Y') . ", ";
$cite .= abs_item_uri($item);
return strip_formatting($cite);
}
add_filter('item_citation', 'item_citation_multiple_creators');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment