Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Add Staff Member Profile Pages in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Add Staff Member Profile Pages in WordPress

Showcasing the people behind your website is a great way to earn customer trust. Previously, we showed you how to create a simple staff list in WordPress. Some of our users wanted to extend their staff lists by adding links next to individual staff member leading to their profile pages. In this article, we will show you how to add staff member profile pages in WordPress.

A preview of staff member profile pages

Note: This tutorial requires some basic knowledge of WordPress themes, and HTML / CSS. Also note that since we will be editing theme files, it is highly recommended that you at least backup your theme files before making any changes to them.

First thing you need to do is install and activate the Simple Staff Lists plugin. Add your staff members by visiting Staff Members » Add New. For more instructions on how to add staff members see this tutorial.

Once you have added your staff members, you can display them by creating a new WordPress page and adding this shortcode:

[simple-staff-list]

So far we have created a simple staff list page, listing all the staff members.

The next part is to create a single page for each staff member to display their complete profiles.

The simple staff lists plugin creates a custom post type called staff-member to store staff member profiles. By placing the shortcode on a page, we have turned that page into a custom post type archive page for the staff-member post type.

In WordPress each post gets its own single page no matter which post type it is stored in. By default the plugin does not show that single page. In the next steps, we will modify our WordPress theme to display the single staff member page.

First you need to go to Staff Members » Templates. Replace the template you see under the Staff Loop Template with this code:

[staff_loop]
	<a href="http://example.com/staff-members/[staff-name-slug]">
<img class="staff-member-photo" src="[staff-photo-url]" alt="[staff-name] : [staff-position]"></a>
	<div class="staff-member-info-wrap">
	<a href="http://example.com/staff-members/[staff-name-slug]">
		[staff-name-formatted]</a>
		[staff-position-formatted]
		[staff-bio-formatted]
		[staff-email-link]
	</div>
[/staff_loop]

Don’t forget to replace example.com with your own domain name.

Now open your staff list page, and you will see that the staff profiles and photos will be linked to their individual profile pages. However clicking on these pages will only show you a page with the Staff Member’s name on it.

Adding a Staff Member Profile Template in Your WordPress Theme

In order to display your single staff member, you need to create a template in your WordPress theme to handle the staff member post type. Start by creating a new file in your WordPress theme directory (wp-content/themes/yourthemename/).

Name this file single-staff-member.php. Using custom post type name with the word single, we have created a single post template for staff member custom post type.

This staff member template is still empty, so lets fill it. Open your theme’s single.php file and copy paste its content into single-staff-member.php template.

One issue that you will come across when copying contents of your single.php file is that some themes may be using content template in the single.php file. For example, the default Twenty Thirteen theme uses content templates in single.php file like this:

<?php get_template_part( 'content', get_post_format() ); ?>

If your theme is using template parts, then you would need to open the template file (content.php) and copy paste its content in you single-staff-member.php file, replacing the get_template_part line.

At this point your single-staff-member.php file will be exactly the same as your single.php file. Now we need to prepare it, so that it can display the fields from staff members.

Here is our single-staff-member.php file, it is based on Twenty Thirteen’s single.php file. First take a look at the code.

<?php
/**
* Single Staff Member
*
*/

get_header(); 

// First we get fields from our staff member custom post type into variables

global $post;
$custom 	= get_post_custom();
$t_name 		= get_the_title();
$name_slug	= basename(get_permalink());
$title 		= $custom["_staff_member_title"][0];
$email 		= $custom["_staff_member_email"][0];
$phone 		= $custom["_staff_member_phone"][0];
$fax 		= $custom["_staff_member_fax"][0];
$bio 		= $custom["_staff_member_bio"][0];
$prof 		= $custom["_staff_member_prof"][0];
$fb_url		= $custom["_staff_member_fb"][0];
$tw_url		= 'http://www.twitter.com/' . $custom["_staff_member_tw"][0];
$li_url		= $custom["_staff_member_li"][0];
if(has_post_thumbnail()){

$t_photo_url = wp_get_attachment_url( get_post_thumbnail_id() );
$t_photo = '<img class="staff-member-page-photo" src="'.$t_photo_url.'" alt = "'.$title.'">';
}else{
$t_photo_url = '';
$t_photo = '';
}
$email_mailto = '<a class="staff-member-email" href="mailto:'.antispambot( $email ).'" title="Email '.$name.'">'.antispambot( $email ).'</a>';
?>	
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">


<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>

<h1><?php the_title(); ?></h1> <!-- This is the Standard page title -->

<h3><?=$title?></h3> <!-- This is the Staff Memeber Title -->

<?=$t_photo?> <!-- This is the Staff Memeber Photo -->

<p class="staff-member-bio"><?=$bio?></p>  <!-- This is the Staff Memeber Bio -->

<p><a href="<?=$fb_url?>">Facebook</a> | <a href="<?=$tw_url?>">Twitter</a></p>
<?php the_content();?>

<?php endwhile; ?>	

</div>

<?php get_sidebar(); ?>	
<?php get_footer(); ?>

In the first part of the code right after loading the header, we have gathered data from our custom post into variables. Then inside the loop we have used those variables to display fields from the custom post type.

That’s all. You may have to adjust the appearance of your profile pages using CSS. We have used this CSS to fit the staff member bio around the photo.


img.staff-member-page-photo { 
float:left;
margin:5px;
}

We hope this article helped you add staff member profile pages in WordPress. Feel free to play around with the templates to get your desired result.

If you liked this article, then subscribe to our YouTube Channel for more WordPress video tutorials. You can also find us on Twitter and Google+.


Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. RCU says:

    Thanks! Great plugin and explanation!!!
    Is there a way to make the staff info open in a pop up window instead of a page?

  2. WPBeginner Staff says:

    We tested it with WordPress 3.9.1 and it works fine.

  3. ognapolean says:

    This plugin hasn’t been test with the latest version, WordPress 3.91.

  4. CANALWP says:

    Aewsome! Thank you guys.

  5. Saggiehaim says:

    Thanks , looked for something like this!

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.