A Better Bio Box
I recently had a request from a clients running a multi-author blog, to incorporate a multi-author bio box. They really needed to credit numerous team members associated with a single blog post or article. It’s easy enough to add new roles in WordPress these days! WordPress has robust built-in Roles and Capabilities system designed to do exactly what you are looking for, but in my clients case the users needed to switch roles dependent on the Post Category. So the user roles needed to change per category which is difficult to say the least. In their case I decided on implementing the Co-Author Plugin and simply tweak the plugin output using a if statement on the single.php file.
As you have probably noticed these scripts were designed for use on a Modeling/Photography site. Assuming you are not running a modeling industry related blog you may need to tweak the base code fields to reflect your own business or special needs.
The [specialty] on line 35 of the code pasted into your users interface is what drives the new roles in the bio.php file. You will need to change both to be the exact same in order to make this function work.After implementing these scripts your wordpress user interface should look something like this:
Now save this code as bio.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
// ---------------------------------------------------------------------*/ // DrDaves Custom Authors Bio Box // User Profile Interface // Dr. Dave's Graphics Better BioBox hack. // http://drdavesgraphics.com/a-better-bio-box/ // ---------------------------------------------------------------------*/ <?php $i = new CoAuthorsIterator(); ?> <div id="author-info"> <!-- <div id="authorbox-title">Authors:</div> --> <?php while($i->iterate()){ ?> <div class="authorboxfix"></div> <div id="author-font"><p><a href=" <?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ) ?>"><?php // the_title(); ?> <?php // rolename could be 'writer' or 'photographer' if (get_the_author_meta('speciality') == "photographer"){ ?> Photographed by: <?php } if(get_the_author_meta('speciality') == "interview"){ ?> Interviewed by: <?php } if(get_the_author_meta('speciality') == "writer"){ ?> Written by: <?php } if(get_the_author_meta('speciality') == "hair"){ ?> Hair Styling by: <?php } if(get_the_author_meta('speciality') == "makeup"){ ?> Makeup Artistry by: <?php } if(get_the_author_meta('speciality') == "fashion"){ ?> Fashion Styling by: <?php } the_author_meta('first_name');?> <?php the_author_meta('last_name');?></a></p></div> <div id="author-image"> <a href="<?php the_author_meta('user_url'); ?>"><?php echo get_avatar( get_the_author_meta('user_email'), '100', '' ); ?></a> </div> <div > <p style="line-height: 14px; margin-top:-5px; color:#141414; padding-right:10px;"><em><?php the_author_meta('description'); ?> <span style="color:#888;"><?php the_author_meta('first_name');?> <?php echo ' has published ' . count_user_posts( get_the_author_meta('ID') ); ?>, articles to GlamModelz Magazine.</span></p></em></div> <?php // if(get_the_author_meta('facebook') || get_the_author_meta('twitter')){ if(get_the_author_meta('sex') == "male"){ ?> <p style="margin-left:5px;" >Connect with him on <?php } if(get_the_author_meta('sex') == "female"){ ?> <p style="margin-left:5px;" >Connect with her on <?php } if (get_the_author_meta('user_url')) { echo '<a href="' . get_the_author_meta('user_url') . '"target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/home.png"></a>'; } if (get_the_author_meta('feedburner')) { echo '<a href="http://feeds.feedburner.com/' . get_the_author_meta('feedburner') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/rss.png"></a>'; } if (get_the_author_meta('blogger')) { echo '<a href="http://' . get_the_author_meta('blogger') . '.blogspot.com/' . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/blogger.png"></a>'; } if (get_the_author_meta('facebook')) { echo '<a href="http://facebook.com/' . get_the_author_meta('facebook') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/facebook.png"></a> '; } if (get_the_author_meta('google')) { echo '<a href="http://plus.google.com/' . get_the_author_meta('google') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/googleplus.png"></a>'; } if (get_the_author_meta('instagram')) { echo '<a href="http://instagram.com/' . get_the_author_meta('instagram') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/instagram.png"></a>'; } if (get_the_author_meta('linkedin')) { echo '<a href="http://linkedin.com/' . get_the_author_meta('linkedin') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/linkedin.png"></a>'; } if (get_the_author_meta('myspace')) { echo '<a href="http://myspace.com/' . get_the_author_meta('myspace') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/myspace.png"></a>'; } if (get_the_author_meta('twitter')) { echo '<a href="http://twitter.com/' . get_the_author_meta('twitter') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/twitter.png"></a>'; } if (get_the_author_meta('flickr')) { echo '<a href="http://flickr.com/photos/' . get_the_author_meta('flickr') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/flickr.png"></a>'; } if (get_the_author_meta('istudio')) { echo '<a href="http://istudio.com/' . get_the_author_meta('istudio') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/istudio.png"></a>'; } if (get_the_author_meta('modelmayhem')) { echo '<a href="http://modelmayhem.com/' . get_the_author_meta('modelmayhem') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/modelmayhem.png"></a>'; } if (get_the_author_meta('omp')) { echo '<a href="http://onemodelplace.com/' . get_the_author_meta('omp') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/omp.png"></a>'; } if (get_the_author_meta('pinterest')) { echo '<a href="http://www.pinterest.com/' . get_the_author_meta('pinterest') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/pinterest.png"></a>'; } if (get_the_author_meta('youtube')) { echo '<a href="http://youtube.com/' . get_the_author_meta('youtube') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/youtube.png"></a>'; } if (get_the_author_meta('vimeo')) { echo ' <a href="http://vimeo.com/' . get_the_author_meta('vimeo') . '" target="_blank"><img style="padding-right:4px;" src="'. get_template_directory_uri() . '/images/social/vimeo.png"></a>'; }?><hr /> <?php } ?> </div> <!-- end Dr Daves Author bio box --> |
After installing and activating the Co-Author Plus plugin add this code to your theme’s function.php file to extend the user designations and functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
// ---------------------------------------------------------------------*/ // DrDaves Custom Authors Bio Box // User Profile Interface // Dr. Dave's Graphics Better BioBox hack. // http://drdavesgraphics.com/a-better-bio-box/ // ---------------------------------------------------------------------*/ /* BEGIN Custom User Contact Info */ // remove aim, jabber, yim function extra_contact_info($contactmethods) { unset($contactmethods['aim']); unset($contactmethods['yim']); unset($contactmethods['jabber']); $contactmethods['feedburner'] = 'FeedBurner ID'; $contactmethods['facebook'] = 'Facebook'; $contactmethods['google'] = 'Google+'; $contactmethods['linkedin'] = 'LinkedIn'; $contactmethods['myspace'] = 'MySpace'; $contactmethods['twitter'] = 'Twitter'; $contactmethods['flickr'] = 'Flickr'; $contactmethods['istudio'] = 'iStudio'; $contactmethods['istagram'] = 'Instagram'; $contactmethods['modelmayhem'] = 'ModelMayhem'; $contactmethods['omp'] = 'OneModelPlace'; $contactmethods['youtube'] = 'YouTube'; $contactmethods['vimeo'] = 'Vimeo'; return $contactmethods; } add_filter('user_contactmethods', 'extra_contact_info'); // Add Gender profile field and speciality (new role) field in user profiles. function add_custom_contactmethod( $contactmethods ) { // Add Gender $contactmethods['sex'] = 'Sex(male/female)'; // Add Speciality $contactmethods['speciality'] = 'photographer/interview/writer/model/makeup/hair/fashion)'; return $contactmethods; } add_filter('user_contactmethods','add_custom_contactmethod' ); // End Dr Daves Graphics Better Bio Box |
Add the following to your Single.php file, just below the loop. This will call the bio.php file below. Notice that I keep all of my custom scripts in a “functions” sub-folder. Adjust your path if you do not!
1 |
include '/functions/bio.php'; // to call Dr Daves Graphics Better Bio Box |
and finally our CSS to make things pretty.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/*----------------------------------------------------------------------*/ /* DrDaves Custom Authors Bio Box /* User Profile Interface /* Dr. Dave's Graphics Better BioBox hack. /* http://drdavesgraphics.com/a-better-bio-box/ /*----------------------------------------------------------------------*/ #author-info { background: #fff; padding: 0px; margin: 0px 0 0 5px; font-size:12px; text-align:justify; overflow: auto; line-height:10px; border:1px solid #ccc;} #author-font{margin:0px 0 0 5px; font-size:16px; font-weight: bold; } #authorbox-title{margin:0 0 0 2px; font-size:14px; font-weight: bold; padding-bottom:0px;} #author-image {float: left; margin:0px 10px 0px 5px ;} .authorboxfix{clear: both;height: 1px;margin: -1px 0 0;overflow: hidden; padding-top:5px;} /* - End Dr Daves Graphics Better Bio Box - */ |