1
上午所有,上WooCommerce定制产品页面有条件地将自定义内容
我创建的代码片段从图像后拉的相关信息,并显示下载的3个选项。
我已经更改了网站的设计以便在Woocommerece的产品上运行,我如何调整我的代码片段以允许此功能工作?
<?php if(in_category(531)) { ?>
<?php if (current_user_can('manage_options')) { ?>
<p>
↓ Download Image<br />
<a href="<?php $image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'web', true);
echo $image_url[0]; ?>" ><img src="<?php bloginfo ('template_url')?>/img/downloadForWeb.png" alt="download for web" /></a><br />
<a href="<?php $image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'print', true);
echo $image_url[0]; ?>" class="download"><img src="<?php bloginfo ('template_url')?>/img/downloadForPrint.png" alt="download for print" /></a><br />
<a href="<?php $image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'', true);
echo $image_url[0]; ?>" class="download"><img src="<?php bloginfo ('template_url')?>/img/downloadForProPrint.png" alt="download for pro print" /></a><br />
</p>
<?php } else { ?>
<h2>Special permission required</h2>
<p>In order to use this image you need special permission from the admin, please fill in the form below and we'll get back to
you as soon as possible...</p>
<?php echo do_shortcode('[contact-form 11 "special permission"]') ?>
<?php } ?>
<?php } else { ?>
<p>
↓ Download Image<br />
<a href="<?php $image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'web', true);
echo $image_url[0]; ?>" ><img src="<?php bloginfo ('template_url')?>/img/downloadForWeb.png" alt="download for web" /></a><br />
<a href="<?php $image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'print', true);
echo $image_url[0]; ?>" class="download"><img src="<?php bloginfo ('template_url')?>/img/downloadForPrint.png" alt="download for print" /></a><br />
<a href="<?php $image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'', true);
echo $image_url[0]; ?>" class="download"><img src="<?php bloginfo ('template_url')?>/img/downloadForProPrint.png" alt="download for pro print" /></a><br />
</p>
<?php } ?>
@LoicTheAztec这里是一个链接,我想它关键词下显示。 http://www.redrocketgraphicdesign.co.uk/test/FIRST/product/firststudent1/ –
@LoicTheAztec这是一个产品页面。当它被设置为一个帖子,它就像这样https://snag.gy/jCDgqK.jpg 你点击你想要的选项,它下载相关的图像,上面的代码是它如何工作的职位。我想切换到在产品页面上工作。 –