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 你點擊你想要的選項,它下載相關的圖像,上面的代碼是它如何工作的職位。我想切換到在產品頁面上工作。 –