Site icon WP Smith

Add the Genesis Author Box to Pages

The Genesis tutorials tells how to set up Author Boxes, how to style Author Boxes, and how to add Author Boxes to Author Archive Pages.

As it currently stands, the author box can only be added to the author archive pages and the single post pages. And from what I see, it doesn't appear on pages like http://domain.com/page-name but does appear on http://domain.com/category/post-name. However, what if I wanted to have the author box appear on all the pages or just some or not on some. Well, here's how to do it.

To insert the author box on ALL pages:
[php]/** Add Genesis Author Box on Single Pages**/
add_action('genesis_after_post', 'genesis_do_author_box_page');
function genesis_do_author_box_page() {
if ( !is_page() )
return;

if ( get_the_author_meta( 'genesis_author_box_single', get_the_author_meta('ID') ) ) {
genesis_author_box( 'single' );
}

}[/php]

To insert the author box on ALL pages except...
[php]/** Add Genesis Author Box on Single Pages**/
add_action('genesis_after_post', 'genesis_do_author_box_page');
function genesis_do_author_box_page() {
$page_exclusions = array(42,'about-me','Contact'); //edit these pages, can take slugs, page names, or page/post ID
if ( ( !is_page() ) || is_page($page_exclusions) )
return;

if ( get_the_author_meta( 'genesis_author_box_single', get_the_author_meta('ID') ) ) {
genesis_author_box( 'single' );
}

}[/php]

To insert the author box on only certain pages:
[php]/** Add Genesis Author Box on Single Pages**/
add_action('genesis_after_post', 'genesis_do_author_box_page');
function genesis_do_author_box_page() {
$page_inclusions = array(42,'about-me','Contact'); //edit these pages, can take slugs, page names, or page/post ID
if ( is_page($page_inclusions) ) {
if ( get_the_author_meta( 'genesis_author_box_single', get_the_author_meta('ID') ) ) {
genesis_author_box( 'single' );
}
}
else
return;

}[/php]