在每一個產品的底部,我想補充一句:回聲產品稱號宇商貿
關於「產品名稱」的任何問題,和我們聯繫
的代碼,我得到我正在使用的是
<h1>Questions about <?php the_product); ?> get in touch</h1>
這似乎不起作用,我該如何在Woocommerce中取出產品名稱?
在每一個產品的底部,我想補充一句:回聲產品稱號宇商貿
關於「產品名稱」的任何問題,和我們聯繫
的代碼,我得到我正在使用的是
<h1>Questions about <?php the_product); ?> get in touch</h1>
這似乎不起作用,我該如何在Woocommerce中取出產品名稱?
請嘗試這一行
<h1>"Any Questions about "<?php echo $the_product; ?>", get in touch with us"</h1>
注意echo
使用打印PHP變量的值,它的名字一樣$ the_product之前在PHP中每個變量有$
。
這不會返回標題,當然標題存儲在數據庫的某個字段,我可以拉它與woo商業產品相當<?php the_title?> –
您只需要產品的echo the_title();
,就像任何文章或網頁一樣。你從哪裏得到$the_product
變量?
這是過時的問題,但如果有人正在尋找像我這些天:
<? echo $product->post->post_title; ?>
或得到充分的HTML標題元素:
<? echo woocommerce_template_single_title(); ?>
Works的Woocommerce 2.5+
乾杯!使用'<?= $ product-> post-> post_title;甚至可以縮短一點。 ?>' – Awilson089
這裏我用於產品頁面標記的內容。
<script type="application/ld+json">{
\t "@context": "http://schema.org/",
"@type": "Product",
"name": "<?php echo the_title(); ?>",
"category": "Designer Fashion Boutique",
"description": "Designer Clothing Store and Online Fashion Boutique",
\t "url": "<?php the_permalink(); ?>"},
</script>
請問'爲你工作? –
budwiser
你在哪裏設置變量$ the_product? – Matheno
看起來像你實際上不是'回聲'變量(假設它有正確的內容) –