Via a request in the WordPress.org forums, here’s an example of how you can extend the Post Author Box plugin with custom tokens:
[sourcecode lang=”php”]/**
* Register token search values with Post Author Box
*/
function db_add_pab_search_values( $tokens ) {
$tokens[] = ‘%coauthors%’;
$tokens[] = ‘%coauthors_posts_links%’;
$tokens[] = ‘%coauthors_firstnames%’;
return $tokens;
}
add_filter( ‘pab_search_values’, ‘db_add_pab_search_values’ );
/**
* Set replacement values for specific tokens with Post Author Box
*/
function db_add_pab_replace_values( $tokens ) {
if ( !function_exists( ‘coauthors’ ) )
return $tokens;
$tokens[‘%coauthors%’] = coauthors( null, null, null, null, false );
$tokens[‘%coauthors_posts_links%’] = coauthors_posts_links( null, null, null, null, false );
$tokens[‘%coauthors_firstnames%’] = coauthors_firstnames( null, null, null, null, false );
return $tokens;
}
add_filter( ‘pab_replace_values’, ‘db_add_pab_replace_values’ );[/sourcecode]
Basically, what you need to do is register the additional tokens on the “pab_search_values” filter, and then set values for each token on the “pab_replace_values” filter.
Feel free to put this in your theme’s functions.php file, or create an MU plugin for it.
One Comment