![](/img/trans.png)
[英]Dinamically create a link using ACF (Advanced Custom Field) custom value
[英]How to Create WPForms Custom Smart Tag with ACF Link Field in Array
我目前正在嘗試使用帶有數組的 ACF 鏈接類型字段設置在 WP Forms 上設置自定義智能標簽。
此過程適用於基於文本的字段,但我在返回任何值時遇到問題,因為它是一個鏈接字段,因此需要捕獲 URL 值。
對於額外的上下文,WP 表單位於單個產品頁面內,它應該捕獲值,但我似乎無法讓它工作。 我試圖默認用智能標簽填充的字段仍然是空白的。
任何建議將不勝感激。
謝謝
片段…
if ("home_report_url" === $tag) {
$homereportlink = get_field_object("home_report_url", get_the_ID());
if($homereportlink) {$home_link_url = $homereportlink['url'];}
$content = str_replace("{home_report_url}", $home_link_url, $content);
}
抱歉造成任何混淆,但我設法通過對 if 語句進行一些更改並添加一個 endif 來使其工作
if ("home_report_url" === $tag) {
$homereportlink = get_field("home_report_url", get_the_ID());
if( $homereportlink ): $home_link_url = $homereportlink['url'];
$content = str_replace("{home_report_url}", $home_link_url, $content);
endif;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.