Support » Plugin: Post Author Box » PHP code in Post Author Box

Viewing 1 replies (of 1 total)
  • Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Hand Built

    Post Author Box is extendable, so it’s totally possible. Add this to the functions.php file in your theme:

    /**
     * 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' );

    This will give you the ability to use these tokens in your Post Author Box:

    %coauthors%
    %coauthors_posts_links%
    %coauthors_firstnames%

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘PHP code in Post Author Box’ is closed to new replies.