WordPress.org

Ready to get started?Download WordPress

Forums

Simple Staff List
[resolved] custom post template for single-staff-member (4 posts)

  1. esaner
    Member
    Posted 7 months ago #

    Hi. Thanks for the great plugin. I need some help getting a custom post type setup for the individual staff pages. I copied my themes single.php file and renamed it single-staff-member.php. I'm not sure what to do next. This post was helpful, but what I could really use is an example of all the code needed to display each field available in the loop. I can style it once it's there.

    Thanks again.

    http://wordpress.org/plugins/simple-staff-list/

  2. NicheLabs
    Member
    Posted 6 months ago #

    I had to add the following code to the top of single-staff-member.php and then use the variables that are set. Hope this helps.

    <?php
    		global $post;
    		$custom 	= get_post_custom();
    		$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()){
    
    			$photo_url = wp_get_attachment_url( get_post_thumbnail_id() );
    			$photo = '<img class="staff-member-photo" src="'.$photo_url.'" alt = "'.$title.'">';
    		}else{
    			$photo_url = '';
    			$photo = '';
    		}
    		$email_mailto = '<a class="staff-member-email" href="mailto:'.antispambot( $email ).'" title="Email '.$name.'">'.antispambot( $email ).'</a>';
    ?>
  3. esaner
    Member
    Posted 5 months ago #

    Worked for me. Thanks!

  4. boutzamat
    Member
    Posted 1 month ago #

    Hi, i tried reading the This post but i dont understand anything from it..

    i tried to clone my template single.php and rename it single-staff-member.php and i added your provided code to it, but still when i click "View staff member" from the edit member page, i land on a 404 page..

    Would it be possible to update the plugin so it has a staffmember site from beginning?

    My single-staff-member.php looks like this:

    <?php
    		global $post;
    		$custom 	= get_post_custom();
    		$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()){
    
    			$photo_url = wp_get_attachment_url( get_post_thumbnail_id() );
    			$photo = '<img class="staff-member-photo" src="'.$photo_url.'" alt = "'.$title.'">';
    		}else{
    			$photo_url = '';
    			$photo = '';
    		}
    		$email_mailto = '<a class="staff-member-email" href="mailto:'.antispambot( $email ).'" title="Email '.$name.'">'.antispambot( $email ).'</a>';
    ?>
    
    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package vantage
     * @since vantage 1.0
     * @license GPL 2.0
     */
    
    get_header(); ?>
    
    <div id="primary" class="content-area">
    	<div id="content" class="site-content" role="main">
    
    	<?php while ( have_posts() ) : the_post(); ?>
    
    		<?php get_template_part( 'content', 'single' ); ?>
    
    		<?php if( siteorigin_setting('navigation_post_nav') ) vantage_content_nav( 'nav-below' ); ?>
    
    		<?php if ( comments_open() || '0' != get_comments_number() ) : ?>
    			<?php comments_template( '', true ); ?>
    		<?php endif; ?>
    
    	<?php endwhile; // end of the loop. ?>
    
    	</div><!-- #content .site-content -->
    </div><!-- #primary .content-area -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

Reply

You must log in to post.

About this Plugin

About this Topic