Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chered/4cc2e2ffc07aed5b7f09e57b4c18c467 to your computer and use it in GitHub Desktop.
Save chered/4cc2e2ffc07aed5b7f09e57b4c18c467 to your computer and use it in GitHub Desktop.
//create shortcode for a coach archive row
function myt_create_shortcode_coach_post_type(){
$args = array(
'post_type' => coach,
'posts_per_page' => 6,
'post_status' => publish
);
$query = new WP_Query($args);
if($query->have_posts()) :
while($query->have_posts()):
$query->the_post() ;
$img_url = get_field('profile_pic');
$credit = get_field('credits');
$coach_link = get_permalink();
$result .= '<div class="column">';
$result .= '<div class="profile-pic"><img src="'.$img_url.'" />' . '</div>';
$result .= '<h2 class="title">' . get_the_title() . '</h2>';
$result .= '<div class="a-credit">'. "Hourly coaching credit rate: " . $credit . '</div>';
$result .= '<div class="p-btn">' . '<a href="'.$coach_link.'" />PROFILE</a>' . '</div>';
$result .= '</div>';
endwhile;
wp_reset_postdata();
endif;
return $result;
}
add_shortcode( 'coach-list', 'myt_create_shortcode_coach_post_type' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment