簡體   English   中英

Woocommerce - 將屬性值動態顯示為錨文本,並將另一個屬性值顯示為 href 鏈接(帶簡碼)

[英]Woocommerce - Dynamically display attribute value as anchor text with another attribute value as the href link (with shortcodes)

我正在創建一個產品頁面模板,我想顯示一個文本鏈接,該鏈接將頂級 URL (externalwebsite.com) 作為錨文本,然后將特定產品頁面 (externalwebsite.com/product) 作為 href 屬性。

我想象 output 的 html 看起來像這樣:

<a href="$product_url_attribute">$brand_url_attribute</a>

我在這個問題上使用@helgatheviking的解決方案來使用簡碼拉取和顯示單個屬性,它非常適合我的需要。

我試過弄亂這段代碼來實現我需要的,但是 PHP 有點讓我頭疼。

如果我還不清楚,請告訴我。

我感謝所有這方面的幫助。

所以,我設法達到了預期的結果,即使它有點笨拙。

我剛剛使用了一個 HTML 塊並寫出了 HTML 並將短代碼插入到它們各自的位置。

<p>View on <a href="[display_attributes attributes='product-url']">[display_attributes attributes="brand-website"]</a></p>

我還必須確保將短代碼中的雙引號更改為單引號,以確保 href 屬性不會提前關閉。

如果您知道更多 eloquent 方法,請告訴我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM