WordPress 简码 return 语法

WordPress shortcode return syntax

我正在尝试在 WordPress 中使用简码功能输出一些 HTML/PHP。 我遇到的问题是语法,我需要在输出中混合 HTML 和 PHP。但我不知道如何正确分离它。

function email_shortcode() {
    return '<a class="email" href="mailto:jobs@company.com?Subject='echo get_field("jo-title") get_field("jo-location")'">Email us</a>';
}
add_shortcode('email', 'email_shortcode');

有人对 return 输出有合适的解决方案吗?

你的代码应该是这样的。

function email_shortcode() {
    return '<a class="email" href="mailto:jobs@company.com?Subject='.get_field("jo-title") .' '.get_field("jo-location").'">Email us</a>';
}
add_shortcode('email', 'email_shortcode');