Skip to content

Instantly share code, notes, and snippets.

@JRGould
Created Mar 3, 2016
Embed
What would you like to do?
<?php
/**
* The template for displaying single Profiles - taken from Twenty Sixteen
*
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
$img = get_field( 'profile-photo' );
$bio = get_field( 'bio' );
$img_src = $img[ 'url' ];
$img_w = $img[ 'width' ];
$img_h = $img[ 'height' ];
$img_alt = $img[ 'description' ] ? $img[ 'description' ] : $img[ 'title' ];
$srcset = '';
foreach ( $img[ 'sizes' ] as $key => $val ) {
if( strstr( $key, '-width' ) || strstr( $key, '-height' ) ) {
continue;
}
$srcset .= $val . ' ' . $img[ 'sizes' ][ $key . '-width' ] . 'w, ';
}
$srcset = substr( $srcset, 0, -2 );
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content no-sidebar">
<img src="<?php echo $img_src; ?>" alt="<?php echo $img_alt; ?>" width=100% srcset="<?php echo $srcset; ?>" class="profile-image">
<p><?php echo $bio; ?></p>
</div>
</article><!-- #post-## -->
<?php
endwhile;
?>
</main><!-- .site-main -->
<?php get_sidebar( 'content-bottom' ); ?>
</div><!-- .content-area -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment