我有來自不同開發人員的多個插件,這些插件允許我顯示亞馬遜產品。 他們都要求我在他們的短碼內輸入亞馬遜類別ID。WordPress將變量傳遞給另一個簡碼
[amazon bestseller="1234567"]
[amz_links node="1234567"]
[amazon_toprated category="1234567"]
我現在用的這些簡碼,在巨大的頁面數量,小部件等 每一個,然後我需要改變的ID,它是一個巨大的麻煩手動改變他們。
我的想法是創建自己的短代碼,如[myamazon_id]
和進入其他簡碼內部的簡碼:[amazon bestseller="[myamazon_id]"]
可惜,這似乎並沒有工作,因爲這些都是自我封閉的簡碼,其中apperantly不要」允許短代碼內的短代碼。
我現在的解決方案是使用一個插件,它允許我在WordPress頁面和小部件中使用PHP。
[insert_php]echo do_shortcode('[amazon bestseller="'.myamazonid().'"]');[/insert_php]
這並不工作,但我不知道是否有一個更好的解決方案,一個varible傳遞到簡碼。直接在頁面和小部件上使用PHP實際上並不是我感覺良好的。
我的目標將是有這樣的事情:此[amazon bestseller="[myamazon_id]"]
這看起來像一個很好的解決方案,但我不能得到它的工作。短代碼的行爲就像沒有提供ID一樣,這導致我認爲'''first_shortcode_amazon'''函數不會將'''myamazon_id''解析爲簡碼,而是作爲普通文本解析。 –