I have my first half of the code which is supposed to be post with thumbnail in classes. One is class item a and other is class item b. But after "else" the code takes the same class item a even if I haven't put it around the code. Why does this happen?
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="item a">
<?php if( has_post_thumbnail() ): ?>
<a href="<?php the_permalink()?>">
<div class="thumbnail"><?php the_post_thumbnail('medium'); ?></div>
</a>
</div>
<div class="item b">
<?php the_title( sprintf('<h3 class="entry-title"><a href="%s">', esc_url( get_permalink() ) ),'</a></h3>' ); ?>
<?php
$content = get_the_content();
$trimmed_content = wp_trim_words( $content, 33, NULL );
echo $trimmed_content;
?>
</div>
<?php else : ?>
<?php the_title( sprintf('<h3 class="entry-title"><a href="%s">', esc_url( get_permalink() ) ),'</a></h3>' ); ?>
<?php
$content = get_the_content();
$trimmed_content = wp_trim_words( $content, 33, NULL );
echo $trimmed_content;
?>
<?php endif; ?>
</article>
The first article is with thumbnail and other is without thumbnail on the image.
Aucun commentaire:
Enregistrer un commentaire