<?php
function team($atts)
{
    extract(shortcode_atts(array(
        'member'       	=> '3',
        'type'       	=> ''
    ), $atts));
    
    $team_return = '';
	if($type == 'style1')
    {
        $args1 = array(
            'post_type'         => array('team'),
            'post_status'       => array('publish'),
            'posts_per_page'    => $member,
            'orderby'           => 'date',
            'order'             => 'DESC'
        );
        
        query_posts($args1);
        if(have_posts())
        {
            
		$team_return .= '<div class="team-list row">';
            while(have_posts())
            {
                the_post();
                $des1 = get_post_meta(get_the_ID(), 'designation', TRUE);
				if($des1 != '')
				{
					$desig = $des1;
				}
				else
				{
					$desig = '';
				}
				
				$ida = get_post_thumbnail_id( get_the_ID() );
				if(has_post_thumbnail( get_the_ID() ))
				{
					$team_thumb = get_the_post_thumbnail(get_the_ID(), 'team_thumb');
				}
				else
				{
					$team_thumb = '<img src="http://placehold.it/263x340/cccccc&amp;text=IMAGE" alt="Team Member">';
				}
				$team_return .='
				<div class="col-md-3 col-sm-6">
					<div class="team-member">
						<div class="team-member-img">
							'.$team_thumb.'
						</div>
						<div class="caption">
							<h3 class="heading">'.get_the_title().'</h3>
							<p>'.esc_attr($desig).'</p>
						</div>
						<ul class="social">';
							$fa = get_post_meta(get_the_ID(), 'facebook', true); if($fa != '') { 
							$team_return .='<li><a target="_blank" href="http://www.facebook.com/'.esc_attr($fa).'" ><i class="fa fa-facebook"></i></a></li>';
							}
							$tw = get_post_meta(get_the_ID(), 'twitter', true); if($tw != '') { 
							$team_return .='<li><a target="_blank" href="http://www.twitter.com/'.esc_attr($tw).'"><i class="fa fa-twitter"></i></a></li>';
							}
							$gp = get_post_meta(get_the_ID(), 'google', true); if($gp != '') { 
							$team_return .='<li><a target="_blank" href="http://www.plus.google.com/'.esc_attr($gp).'"><i class="fa fa-google-plus"></i></a></li>';
							}
							$lin = get_post_meta(get_the_ID(), 'linkedin', true); if($lin != '') { 
							$team_return .='<li><a target="_blank" href="http://www.linkedin.com/in/'.esc_attr($lin).'/" ><i class="fa fa-linkedin"></i></a></li>';
							}
						$team_return .='</ul>
					</div>
				</div>';
            }
		$team_return .= '</div>';
        }
        else
        {
            $team_return .= '<div class="col-lg-12 text-center">';
                $team_return .= '<h1 class="common_main_heading">Please Insert Some <span>Team</span> First.</h1>';
            $team_return .= '</div>';
        }
        wp_reset_query();
    }
    elseif($type == 'style2')
    {
		$args1 = array(
            'post_type'         => array('team'),
            'post_status'       => array('publish'),
            'posts_per_page'    => $member,
            'orderby'           => 'date',
            'order'             => 'DESC'
        );
        
        query_posts($args1);
        if(have_posts())
        {
            
		$team_return .= '<div class="team-list style-2 row">';
            while(have_posts())
            {
                the_post();
                $des1 = get_post_meta(get_the_ID(), 'designation', TRUE);
				if($des1 != '')
				{
					$desig = $des1;
				}
				else
				{
					$desig = '';
				}
				
				$ida = get_post_thumbnail_id( get_the_ID() );
				if(has_post_thumbnail( get_the_ID() ))
				{
					$team_thumb = get_the_post_thumbnail(get_the_ID(), 'team_thumb');
				}
				else
				{
					$team_thumb = '<img src="http://placehold.it/263x340/cccccc&amp;text=IMAGE" alt="Team Member">';
				}
				$team_return .='
				<div class="col-md-3 col-sm-6">
					<div class="team-member style-2">
						<div class="team-member-img">
							'.$team_thumb.'
						</div>
						<div class="caption">
							<h3 class="heading">'.get_the_title().'</h3>
							<p>'.esc_attr($desig).'</p>
						</div>
					</div>
				</div>';
            }
		$team_return .= '</div>';
        }
        else
        {
            $team_return .= '<div class="col-lg-12 text-center">';
                $team_return .= '<h1 class="common_main_heading">Please Insert Some <span>Team</span> First.</h1>';
            $team_return .= '</div>';
        }
        wp_reset_query();
	}
    return $team_return;
}
add_shortcode( "rms-team", "team" );