English 中文(简体)
WooCommerce - 添加 lo体内的产品链接
原标题:WooCommerce - add link to product in loop

我认为,这应该非常简单,但我正在寻找15名未成年人,并且可以发现:

我有一个把产品列入某类的圈子,我需要加以修改,以便照片和所有权与单个产品页联系起来。 与此相似的是我所期待的。

<a href="<?php echo woocommerce_get_the_permalink() ?>">

这是我拥有的:

 <?php
    $args = array(  post_type  =>  product ,  posts_per_page  => 4,  product_cat  =>  power-chairs ,  orderby  =>  ID  );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
            <div class="product">  
                <div class="padding">
                        <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID); else echo  <img src=" .woocommerce_placeholder_img_src(). " alt="Placeholder"/> ; ?>
                        <p class="caption"><?php the_title(); ?></p>
                </div><!-- padding -->
            </div><!-- product -->
<?php endwhile; ?>

Edit: 创始者——是“植被_permalink(产品_id)”

问题回答

您是否尝试在图像和标题上添加<代码>a href链接:

<?php
$args = array(  post_type  =>  product ,  posts_per_page  => 4,  product_cat  =>  power-chairs ,  orderby  =>  ID  );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
        <div class="product">  
            <div class="padding">
                   <a href="<?php echo woocommerce_get_the_permalink() ?>">

                    <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID); else echo  <img src=" .woocommerce_placeholder_img_src(). " alt="Placeholder"/> ; ?></a>
                    <p class="caption"><a href="<?php echo woocommerce_get_the_permalink() ?>"><?php the_title(); ?></a></p>

            </div><!-- padding -->
        </div><!-- product -->




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签