Skip to content

Instantly share code, notes, and snippets.

@deckerweb
Last active December 28, 2015 19:29
Show Gist options
  • Select an option

  • Save deckerweb/7551088 to your computer and use it in GitHub Desktop.

Select an option

Save deckerweb/7551088 to your computer and use it in GitHub Desktop.
In Genesis Framework load other Google Authorship than the default - only for a specific page (or an array of pages or whatever...)
<?php
/** Do NOT include the opening php tag */
add_action( 'wp_head', 'ddw_tweak_google_rel_author', 5 );
/**
* Remove default Google Plus author URL and re-add another specific one - for a specific page only.
*
* @author David Decker - DECKERWEB
* @link http://deckerweb.de/twitter
*/
function ddw_tweak_google_rel_author() {
/** Array of our page IDs */
$custom_pages = array( 2, 16324 ); // Comma separated Page IDs, for example: 2 and 16324
/** Only for specific page(s) */
if ( is_page( $custom_pages ) ) {
/** Remove Genesis default */
remove_action( 'wp_head', 'genesis_rel_author' );
/** Set our own */
add_action( 'wp_head', 'ddw_custom_page_rel_publisher', 15 );
} // end if
} // end function
/**
* Insert our Google Plus author URL for the specific page.
*
* NOTE I: use rel="publisher" for Google+ PAGES!
* NOTE II: use rel="author" for Google+ Personal Profiles!
*
* @author David Decker - DECKERWEB
* @link http://deckerweb.de/twitter
*
* @global $post
*/
function ddw_custom_page_rel_publisher() {
/** Get post object */
global $post;
/** Set our link */
$gplus_url = 'http://your-google-plus-page-url-here.com/';
/** Do the magic */
if ( isset( $post->post_author ) && $gplus_url ) {
printf( '<link rel="publisher" href="%s" />' . "\n", esc_url( $gplus_url ) );
return;
} // end if
} // end function
@deckerweb

Copy link
Copy Markdown
Author

PLEASE NOTE THIS:

Your Google+ URL for your personal author profile is different than a Google+ PAGE URL!
For PAGES use: rel="publisher" within the < a > Tag
For personal profiles use: rel="author" < a > Tag (like it is the default in Genesis 1.9.x or higher!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment