<?php
//Featured Case Studies
add_shortcode('case_study', 'case_study_home');
function case_study_home()
{
ob_start();
echo '<div id="feature-case-study">';
$args = array(
'post_type' => 'case-studies',
'posts_per_page' => 4,
'featured' => 'yes',
'order' => 'rand'
);
$resData = new WP_Query($args);
if ($resData->have_posts()) :
while ($resData->have_posts()) :
$resData->the_post();
?>
<div>
<div class="col-md-6 col-lg-6 col-xs-12 element1">
<?php
$image = get_the_post_thumbnail(get_the_ID(), '', array('class' => 'img-responsive'));
echo $image;
?>
</div>
<div class="col-md-6 col-lg-6 col-xs-12"><!------SVG 1 of 2------>
<div class="box-item">
<?php $categories = get_the_category();
foreach ($categories as $cat) {
echo '<a href="' . esc_url(get_category_link($cat->term_id)) . '" class="button_hover tag_btn">' . esc_html($cat->name) . '</a>';
} ?>
<?php the_title('<h4>', '</h4>'); ?>
<?php the_content(__('(more...)')); ?>
<a href="<?php the_permalink(); ?>" class="btn btn-yellow">Read the case study</a>
</div>
</div>
</div>
<?php endwhile; ?>
<?php
else:
echo '<h2>No case studies found<h2>';
endif;
echo '</div>';
wp_reset_postdata();
return ob_get_clean();
}
?>
Show Comments
