L
L
ligisayan2017-12-15 13:26:26
HTML
ligisayan, 2017-12-15 13:26:26

How to put an image inside the wordpress loop?

Hello! There is a standard loop in wordpress . Interested in how it is inside the standard announcement cycle (limit of 7 articles)

<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>

<li> 
  <span class="li--span"><span class="li--span--category"><?php the_category( ', ' ); ?></span></span>   
  <a href="<?php the_permalink() ?>" class="li--a">                                        
    <span class="little_content"><?php the_title(); ?></span>   
  </a>                                
</li>

<?php endwhile; ?>

Display the image after the 4th announcement, i.e. there should be 4 entries - picture - 3 more entries after
<a href="#"><img src="<?php echo get_template_directory_uri() ?>/img/advertisement.jpg" width="300" height="500" title="Перейти на сайт рекламодателя" /></a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2017-12-15
@ligisayan

<?php $i = 1; if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<li> 
  <span class="li--span"><span class="li--span--category"><?php the_category( ', ' ); ?></span></span>   
  <a href="<?php the_permalink() ?>" class="li--a">                                        
    <span class="little_content"><?php the_title(); ?></span>   
  </a>                                
</li>
<?php if ( $i == 4 ) { echo 'картинка'; } ?>">
<?php $i++; endwhile; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question