我已經搜索了一段時間的這個問題,也許它很簡單,也許沒有。我無法弄清楚如何讓這個工作。
我的目標結果將是一個超鏈接與後meta有關的一些樣式如此。
<a href="href_link" style="color: #e67300" rel="nofollow"> Check out the r_title here!</a>
我的代碼是:
<?php
$rtitle1 = get_post_meta($post->ID, 'r_title', true);
$rlink1 = get_post_meta($post->ID, 'href_link', true);
function testfunction() {
$output .= '<a href=\"'$rlink1'\" style=\"color: #e67300\" rel=\"nofollow\">';
$output .= ' Check out the '$rtitle1' here!</a>';
return $output;
}
add_shortcode('shortcode', 'testfunction');
?>
你不需要在單引號內換掉雙引號 –