WordPress.org

Ready to get started?Download WordPress

Forums

Post Author Box
PHP code in Post Author Box (2 posts)

  1. raynevandunem
    Member
    Posted 2 years ago #

    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.

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic