我已经搜索了一段时间的这个问题,也许它很简单,也许没有。我无法弄清楚如何让这个工作。
我的目标结果将是一个超链接与后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');
?>
你不需要在单引号内换掉双引号 –