Skip to content

Instantly share code, notes, and snippets.

@amberhinds
Last active September 13, 2016 08:20
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 amberhinds/b1eabfa5770b69f54e1bfae51ff0d2b7 to your computer and use it in GitHub Desktop.
Save amberhinds/b1eabfa5770b69f54e1bfae51ff0d2b7 to your computer and use it in GitHub Desktop.
speakers shortcode
<?php
if (!function_exists('wpt_speakers')) {
function wpt_speakers( $atts, $content = null ) {
extract(shortcode_atts(array(
'event'=> '',
'class' => '',
), $atts));
$t = get_term_by( 'slug', $levelsp, 'levelsp' );
$out="</div><div class='row-fluid speaker-level'>".do_shortcode('[title-bordered]'.strtoupper($t->name).'[/title-bordered]')."</div><div class='row-fluid'>";
if($event!=''){
$args=array(
'post_type'=>'speakers',
'meta_key'=>'speaker_lastname',
'order_by'=>'meta_value',
'order'=>'ASC',
'posts_per_page'=>-1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'summits',
'field' => 'slug',
'terms' => $event
)
),
);
if( $levelsp != '' ){
$args['tax_query'][]= array(
'taxonomy' => 'levelsp',
'field' => 'slug',
'terms' => $levelsp
);
}
// print_r($args);
$q=new WP_Query($args);
if ($q->have_posts()) :
while ($q->have_posts()) : $q->the_post();
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size = 'thumbnail' );
$title=get_post_meta(get_the_ID(),'wpt_title',true);
$company=get_post_meta(get_the_ID(),'wpt_company',true);
$linkedin=get_post_meta(get_the_ID(),'wpt_company',true);
$twitterurl=get_post_meta(get_the_ID(),'wpt_twitter',true);
if ($twitterurl) {
$twitter='<a target="_blank" href="http://twitter.com/'.$twitterurl.'"><img src="http://lesbianswhotech.org/wp-content/uploads/2013/11/32x32_twitter.png" alt="twitter"></a>';
} else {
$twitter='<div></div>';
}
$linkedinurl=get_post_meta(get_the_ID(),'linkedin_url',true);
if ($linkedinurl) {
$linkedin='<a target="_blank" href="'.$linkedinurl.'"><img src="http://lesbianswhotech.org/wp-content/uploads/2013/11/32x32_linkedin.png" alt="linkedin"></a>';
} else {
$linkedin='<div></div>';
}
$out.='<div class="col-lg-3 col-md-3 col-sm-6 speaker">
<a href="'. get_permalink() .'">
<div class="image"><img alt="'.get_the_title().'" src="'.$image[0].'" /></div>
<div class="overlay">
<div class="details">
<div class="name">'.get_the_title().'</div>
<div class="title">'.$title.'</div>
<div class="title"> '.$company.'</div>
<div class="social-links"> '.$twitter.$linkedin.'</div>
</div>
</div>
</a>
</div>';
endwhile;
endif;
wp_reset_query();
}
$out .= '</div>';
return $out;
}
add_shortcode('speakers', 'wpt_speakers');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment