簡體   English   中英

如何使用動態鏈接創建 php 短代碼?

[英]How to create php shortcode with dynamic link?

我在創建 WordPress 短代碼時遇到了一些麻煩,因此我可以將它放在我的 Elementor 頁面模板下。

// Shortcode to output custom PHP in Elementor
function luxis_ics_endpoint( $atts ) {
    return '<a href="'.<?php echo get_feed_link("calendar"); ?>?id=<?php echo get_the_ID(); ?>"> Download .ics </a>';
        
}
add_shortcode( 'my_elementor_php_output', 'luxis_ics_endpoint');

所以返回,我不知道如何正確編寫它,以便它可以獲取那些 PHP 代碼並在短代碼中生成一個鏈接供我在前端使用。

任何建議將不勝感激!

您的代碼看起來正確。 您需要echo顯該功能-在這種情況下不return

暫無
暫無

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

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