Mixitup动态图像的壮观弹出窗口问题

我只是在我的网站上手动设置了同位素,然后借助get_terms和get_ther_terms对其进行了动态处理,条件是完整的代码


     <div class="main_page">

<div class="portfolio_section">

          <div class="controls">
       <button type="button" class="control" data-filter="all">All</button>

        <?php

          $cat_list = get_terms('filters');

          foreach ($cat_list as $cat) :
          ?>
    <button type="button" class="control" data-filter=".<?php echo $cat->slug;?>"><?php echo $cat->name; ?></button>


      <?php endforeach; ?>


     </div>

   <div class="container pasresnt">

     <?php
         $mixitup = new WP_Query(array(
             'post_type' => 'portfolio','posts_per_page' => -1,));

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

<div class="mix <?php

           $cat_slug = get_the_terms($post->ID,'filters');
           foreach ($cat_slug as $cat_sl) {
            echo $cat_sl->slug;
           }

           ?>">



            <a href="<?php the_post_thumbnail('portfolio-small'); ?>" target="_blank"><?php the_post_thumbnail('portfolio-small'); ?> </a>


         </div>

 <?php endwhile; ?>
         <div class="mix green">

      <a href="<?php echo get_template_directory_uri(); ?>/img/mahi.jpg"><img src="<?php echo get_template_directory_uri(); ?>/img/mahi.jpg"

alt=""></a>

</div>

</div>
 </div>

 </div>

以下是此代码正确显示的常规静态图片弹出窗口中的亮点

 <a href="<?php echo get_template_directory_uri(); ?>/img/mahi.jpg"><img src="<?php echo get_template_directory_uri(); ?>/img/mahi.jpg"

alt=""></a>

但是在动态模式下,此图像弹出窗口对我不起作用。最后一个静态示例是完美的示例,但是此行代码(即图像来自投资组合自定义帖子选项)无法弹出

<a href="<?php echo $for_img; ?>" target="_blank"><?php the_post_thumbnail('portfolio-small'); ?> </a>

`

iCMS 回答:Mixitup动态图像的壮观弹出窗口问题

您正在将the_post_thumbnail用于href。这样会输出html以显示图像,但是您只希望将URL放入链接的href属性中,因此请使用get_the_post_thumbnail_url()

所以代替这个:

<a href="<?php the_post_thumbnail('portfolio-small'); ?>" target="_blank"><?php the_post_thumbnail('portfolio-small'); ?> </a>

您应该使用此:

<a href="<?php echo get_the_post_thumbnail_url(get_the_ID(),'portfolio-small'); ?>" target="_blank">
    <?php the_post_thumbnail('portfolio-small'); ?>
</a>
本文链接:https://www.f2er.com/2024449.html

大家都在问