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

  • Hi, I’m using a plugin entitled “Co-Authors Plus”, which allows for multiple authors to be attached to the credits of a single post when necessary. I want the multiple authors to be attached through the Post Author Box as well, but I’m not sure if this plugin will take PHP code alongside tokens and HTML code.

    Here are the PHP shortcodes in question: http://wordpress.org/extend/plugins/co-authors-plus/other_notes/

    Thanks for any answer or, if possible, solution.

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

    (@danielbachhuber)

    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.