Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GaryJones/a5c5ea78bf4fe177ab87 to your computer and use it in GitHub Desktop.
Save GaryJones/a5c5ea78bf4fe177ab87 to your computer and use it in GitHub Desktop.
<?php
// Add a post signature for multiple authors.
// All signature divs will have a class of .signature for common styling
// then .signature-cat as the default and .signature-tracey for the guest
// as class modifiers (different background image, or background position
// if using sprites etc.)
// If it's not a single entry of any post type, return.
if ( is_single() ) {
return;
}
// Defaults for main author.
$class_suffix = 'tracey';
$name = 'Tracey';
// Cat is the guest.
$cat_user_id = 2; // Change this to Cat's user ID.
if ( get_the_author_meta( 'user_id' ) == $cat_user_id ) {
$class_suffix = 'cat';
$name = 'Cat';
}
// Name added for better accessibility - you can use the .signature class to
// implement your favourite image replacement technique.
?>
<p class="signature <?php echo sanitize_class_html( 'signature-' . $class_suffix ); ?>"><?php echo esc_html( $name ); ?></p>
@GaryJones
Copy link
Author

Be sure to change the guest's user ID!

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