Created
November 30, 2018 21:55
-
-
Save sophiawzey/3396d1f25d9dcb2067e1e38c007087ba to your computer and use it in GitHub Desktop.
[Case Study Listing] #wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// just the listing part | |
$args = array( | |
'post_type' => 'case-study', | |
'posts_per_page' => - 1, | |
'order' => 'ASC', | |
'orderby' => 'menu_order' | |
); | |
$parent = new WP_Query( $args ); | |
if ( $parent->have_posts() ) : ?> | |
<?php while ( $parent->have_posts() ) : $parent->the_post(); ?> | |
<?php | |
$img = get_field( 'teaser_image' ); | |
$teaser = get_field( 'teaser_body_copy' ); | |
$teaserTitle = get_the_title(); | |
$cta = get_field( 'teaser_button_text' ); | |
if ( $img ) { | |
$imgUrl = $img['url']; | |
} else { | |
$imgUrl = '/wp-content/uploads/2018/10/Y-Axis-Milling.jpg'; | |
} | |
?> | |
<div id="teaser-<?php the_ID(); ?>" class="teaser"> | |
<a href="<?php the_permalink(); ?>" title="<?php echo $teaserTitle ?>"> | |
<div class="teaser__wrapper grid-x"> | |
<div class="teaser__image cell large-8" | |
style="background:url(<?= $imgUrl ?>) no-repeat center; background-size:cover;"></div> | |
<div class="teaser__text cell large-4"> | |
<h3 class="teaser__title"><?php echo $teaserTitle ?></h3> | |
<div class="teaser__body"> | |
<?php echo $teaser ?> | |
<div class="button"><?php echo $cta ?><span class="fas fa-chevron-right"></span> | |
</div> | |
</div> | |
</div> | |
</div> | |
</a> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; | |
wp_reset_postdata(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment