I am job-searching and putting together some code samples. Just wondering how it looks.
I am job-searching and putting together some code samples. Just wondering how it looks.
Homepage Template
I'm also wondering if these samples are long enough. I could also include the code from the partials.
Partials
callout
<?php
/* Callout, links to contact page. */
?>
<section class="callout"><a href="<?php echo site_url('/contact/'); ?>">
<div class="container">
<div class="text">
<span class="icon-calendar solo"></span>
<h2 class="h1"><?php _e('Schedule a Discussion','ssae'); ?></h2>
</div>
</div>
</a></section>
details
<?php
/* Display a title, block of text, and icon for each item. Items pulled from a repeater field in the backend. */
?>
<?php
while ( have_rows('details') ) : the_row();
$title = get_sub_field('title');
$icon_class = get_sub_field('icon_class');
$text = get_sub_field('text');
?>
<div class="detail">
<span class="icon-<?php echo $icon_class; ?> solo"></span>
<h2><?php echo $title; ?></h2>
<?php echo $text; ?>
</div>
<?php
endwhile;
?>
testimonials
<?php
/* Display the 3 Most Recent Testimonials (a custom post type) */
?>
<?php
$loop = new WP_Query( array(
'post_type' => 'testimonials',
'posts_per_page' => 3
) );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<?php
$thumb_id = get_post_thumbnail_id($post->id);
$thumbnail = wp_get_attachment_image_src( $thumb_id, 'thumbnail' );
$thumb_alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
$logo_id = get_field('logo');
$logo = $logo_id['sizes']['grid-thumb'];
$logo_alt = get_post_meta($logo_id, '_wp_attachment_image_alt', true);
?>
<div class="testimonial"><div class="wrap">
<div class="header">
<div class="headshot">
<img src="<?php echo $thumbnail[0]; ?>" alt="<?php echo $thumb_alt; ?>">
</div>
<p class="subheading"><?php the_title(); ?></p>
</div>
<div class="text">
<?php the_content(); ?>
</div>
<?php if ( is_page_template('startups-page.php') ) : ?>
<img class="logo" src="<?php echo $logo; ?>"> <!-- needs an alt attribute -->
<?php endif; ?>
</div></div>
<?php endwhile; wp_reset_query(); ?>
featured-cs
<?php
/* Display selected case studies (a custom post type). Items are chosen in a custom field for this page in the backend. */
?>
<section class="featured case-studies">
<h1><?php _e('Case Studies','ssae'); ?></h1>
<div class="gallery"><div class="container">
<?php if( have_rows('case_studies')):
while ( have_rows('case_studies')) : the_row();
$post_object = get_sub_field('post');
if( $post_object ) :
$post = $post_object;
setup_postdata($post);
get_template_part('partials/article');
wp_reset_postdata();
endif;
endwhile;
endif; ?>
</div></div>
</section>
article
<?php
/* Layout for displaying a thumbnail, title, link, and categories for an article. */
?>
<a class="article" href="<?php the_permalink() ?>">
<div class="image">
<?php if ( has_post_thumbnail() ) :
echo get_the_post_thumbnail( $post->ID, 'grid-thumb');
else : ?>
<img src="https://placehold.it/600x440" alt="placeholder" />
<?php endif; ?>
</div>
<h2><?php the_title(); ?></h2>
<span class="category">
<?php
/* show a comma-separated list of associated categories as just text, no links */
$cats = '';
foreach((get_the_category()) as $category) {
if ($category->cat_name != "Uncategorised") { // don't print this "category"
$cats .= $category->cat_name . ', ';
}
}
echo rtrim($cats, ', ');
?>
</span>
</a>
I'm also wondering if these samples are long enough. I could also include the code from the partials.
Homepage Template
Partials
callout
<?php
/* Callout, links to contact page. */
?>
<section class="callout"><a href="<?php echo site_url('/contact/'); ?>">
<div class="container">
<div class="text">
<span class="icon-calendar solo"></span>
<h2 class="h1"><?php _e('Schedule a Discussion','ssae'); ?></h2>
</div>
</div>
</a></section>
details
<?php
/* Display a title, block of text, and icon for each item. Items pulled from a repeater field in the backend. */
?>
<?php
while ( have_rows('details') ) : the_row();
$title = get_sub_field('title');
$icon_class = get_sub_field('icon_class');
$text = get_sub_field('text');
?>
<div class="detail">
<span class="icon-<?php echo $icon_class; ?> solo"></span>
<h2><?php echo $title; ?></h2>
<?php echo $text; ?>
</div>
<?php
endwhile;
?>
testimonials
<?php
/* Display the 3 Most Recent Testimonials (a custom post type) */
?>
<?php
$loop = new WP_Query( array(
'post_type' => 'testimonials',
'posts_per_page' => 3
) );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<?php
$thumb_id = get_post_thumbnail_id($post->id);
$thumbnail = wp_get_attachment_image_src( $thumb_id, 'thumbnail' );
$thumb_alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
$logo_id = get_field('logo');
$logo = $logo_id['sizes']['grid-thumb'];
$logo_alt = get_post_meta($logo_id, '_wp_attachment_image_alt', true);
?>
<div class="testimonial"><div class="wrap">
<div class="header">
<div class="headshot">
<img src="<?php echo $thumbnail[0]; ?>" alt="<?php echo $thumb_alt; ?>">
</div>
<p class="subheading"><?php the_title(); ?></p>
</div>
<div class="text">
<?php the_content(); ?>
</div>
<?php if ( is_page_template('startups-page.php') ) : ?>
<img class="logo" src="<?php echo $logo; ?>"> <!-- needs an alt attribute -->
<?php endif; ?>
</div></div>
<?php endwhile; wp_reset_query(); ?>
featured-cs
<?php
/* Display selected case studies (a custom post type). Items are chosen in a custom field for this page in the backend. */
?>
<section class="featured case-studies">
<h1><?php _e('Case Studies','ssae'); ?></h1>
<div class="gallery"><div class="container">
<?php if( have_rows('case_studies')):
while ( have_rows('case_studies')) : the_row();
$post_object = get_sub_field('post');
if( $post_object ) :
$post = $post_object;
setup_postdata($post);
get_template_part('partials/article');
wp_reset_postdata();
endif;
endwhile;
endif; ?>
</div></div>
</section>
article
<?php
/* Layout for displaying a thumbnail, title, link, and categories for an article. */
?>
<a class="article" href="<?php the_permalink() ?>">
<div class="image">
<?php if ( has_post_thumbnail() ) :
echo get_the_post_thumbnail( $post->ID, 'grid-thumb');
else : ?>
<img src="https://placehold.it/600x440" alt="placeholder" />
<?php endif; ?>
</div>
<h2><?php the_title(); ?></h2>
<span class="category">
<?php
/* show a comma-separated list of associated categories as just text, no links */
$cats = '';
foreach((get_the_category()) as $category) {
if ($category->cat_name != "Uncategorised") { // don't print this "category"
$cats .= $category->cat_name . ', ';
}
}
echo rtrim($cats, ', ');
?>
</span>
</a>
Hey all – New to Code Review! I am job-searching and putting together some code samples. Just wondering how it looks.
Here is an example of some code, from a custom wordpressWordPress theme, that works and is in production.:
<?php
/*
Template Name: Homepage
Requirements: Advanced Custom Fields plugin
*/
?>
<?php get_header(); ?>
<section class="hero">
<div class="container">
<main>
<p class="h1">
<?php the_field('hero_content'); ?>
</p>
</main>
</div>
<div class="testimonials">
<ul class="slider">
<?php get_template_part('partials/testimonials'); ?>
</ul>
</div>
</section>
<main id="main">
<?php the_content(); ?>
<div class="details">
<div class="heading">
<h1><?php _e('What We Build','ssae'); ?></h1>
</div>
<?php get_template_part('partials/details'); ?>
</div>
<div class="stats">
<?php
while ( have_rows('stats') ) : the_row();
$label = get_sub_field('label');
$value = get_sub_field('value');
?>
<div class="stat">
<div class="label"><?php echo $label; ?></div>
<div class="value"><?php echo $value; ?></div>
</div>
<?php
endwhile;
?>
</div>
</main>
<?php get_template_part('partials/callout'); ?>
<?php get_template_part('partials/featured-cs'); ?>
<?php get_footer(); ?>
I'm also wondering if these sample issamples are long enough. I could also include the code from the partials...
Thanks!
Hey all – New to Code Review! I am job-searching and putting together some code samples. Just wondering how it looks.
Here is an example of some code, from a custom wordpress theme, that works and is in production.
<?php
/*
Template Name: Homepage
Requirements: Advanced Custom Fields plugin
*/
?>
<?php get_header(); ?>
<section class="hero">
<div class="container">
<main>
<p class="h1">
<?php the_field('hero_content'); ?>
</p>
</main>
</div>
<div class="testimonials">
<ul class="slider">
<?php get_template_part('partials/testimonials'); ?>
</ul>
</div>
</section>
<main id="main">
<?php the_content(); ?>
<div class="details">
<div class="heading">
<h1><?php _e('What We Build','ssae'); ?></h1>
</div>
<?php get_template_part('partials/details'); ?>
</div>
<div class="stats">
<?php
while ( have_rows('stats') ) : the_row();
$label = get_sub_field('label');
$value = get_sub_field('value');
?>
<div class="stat">
<div class="label"><?php echo $label; ?></div>
<div class="value"><?php echo $value; ?></div>
</div>
<?php
endwhile;
?>
</div>
</main>
<?php get_template_part('partials/callout'); ?>
<?php get_template_part('partials/featured-cs'); ?>
<?php get_footer(); ?>
I'm also wondering if these sample is long enough. I could also include the code from the partials...
Thanks!
Here is an example of some code, from a custom WordPress theme, that works and is in production:
<?php
/*
Template Name: Homepage
Requirements: Advanced Custom Fields plugin
*/
?>
<?php get_header(); ?>
<section class="hero">
<div class="container">
<main>
<p class="h1">
<?php the_field('hero_content'); ?>
</p>
</main>
</div>
<div class="testimonials">
<ul class="slider">
<?php get_template_part('partials/testimonials'); ?>
</ul>
</div>
</section>
<main id="main">
<?php the_content(); ?>
<div class="details">
<div class="heading">
<h1><?php _e('What We Build','ssae'); ?></h1>
</div>
<?php get_template_part('partials/details'); ?>
</div>
<div class="stats">
<?php
while ( have_rows('stats') ) : the_row();
$label = get_sub_field('label');
$value = get_sub_field('value');
?>
<div class="stat">
<div class="label"><?php echo $label; ?></div>
<div class="value"><?php echo $value; ?></div>
</div>
<?php
endwhile;
?>
</div>
</main>
<?php get_template_part('partials/callout'); ?>
<?php get_template_part('partials/featured-cs'); ?>
<?php get_footer(); ?>
I'm also wondering if these samples are long enough. I could also include the code from the partials.