G
G
German Zuiakov2021-08-23 00:55:43
WordPress
German Zuiakov, 2021-08-23 00:55:43

Have_post() loop not working properly?

There is a loop for getting posts:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
          <a href="<?php echo get_permalink();?>">
            <article class="col project-card">
              <div class="project-outer">
                <div class="project-image">
                  <?php echo the_post_thumbnail('project-thumbnail'); ?>
                </div>
                <div class="project-text">
                  <h3><?php the_title();?></h3>
                  <div class="project-info">
                    <div class="project-square">
                      <div class="project-info-img">
                        <img src="<?php echo esc_url( get_template_directory_uri() ); ?>/img/info.svg" alt="">
                      </div>
                      <span><?php echo get_post_meta(get_the_ID(), '_k_area', true); ?>м&#0178;</span>
                    </div>
                    <div class="project-price">
                      <?php $sale = get_field('project-sale');
                      if( $sale && in_array('checked', $sale) ) {
                      ?>
                      <p class="sale"><?php echo get_post_meta(get_the_ID(), '_k_price_max', true); ?>&euro;</p>
                      <strong>от <?php the_field('project-price-1'); ?>&euro;</strong>
                      <?php
                      }else{?>
                      <strong><?php echo get_post_meta(get_the_ID(), '_k_price_max', true); ?>&euro;</strong>
                      <?php
                         }
                      ?>
                    </div>  
                  </div>
                </div>
                <a class="project-link" href="">Подробнее</a>
              </div>
            </article>
          </a>
                <?php endwhile;  endif;?>


As a result, it produces this html:
6122c7dc71133700867011.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
viktorleg, 2021-08-23
@HermanZuiakov

Because you have a link <a class="project-link" href="">Подробнее</a>within a link. Either make the button more detailed a link, or the entire card.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question