I have my carousel working: http://worldwayssocialmarketing.org/louisiana/ I'm trying to write the code to place the featured image, title, and except of a page marked category "home-banner" in WordPress. I would also like to place a default image from my img folder if no thumbnail exists.
This isn't working:
<?php if( is_category('home-banner') ){ ?>
<div class="homecards">
<div class="owl-item grayscale" style="width: 80%; height:300px;">
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src="<?php bloginfo('template_directory'); ?>/img/default-image.jpg" alt="<?php the_title(); ?>" />
<?php } ?></div>
<h2><?php the_title(); ?></h2>
<p><?php the_excerpt(); ?></p>
</div>
<?php } ?>
Nevermind... I figured it out :-)
<?php query_posts( 'category_name=home-banner' ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="homecards">
<div class="homecardimg">
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src="<?php bloginfo('template_directory'); ?>/img/default-image.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
</div>
<h2><?php the_title(); ?></h2><br>
<p><?php the_excerpt(); ?></p>
</div>
<?php endwhile; ?>