Skip to content

Instantly share code, notes, and snippets.

@JRGould
Created March 3, 2016 02:47
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 JRGould/76f636382f5b5c01a3e0 to your computer and use it in GitHub Desktop.
Save JRGould/76f636382f5b5c01a3e0 to your computer and use it in GitHub Desktop.
<?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