只是按照教程从头创建了一个自定义字段。我有一个网站链接字段。目前它只输出原始文本,没有链接。
那么,如何使此代码超链接:
<li><strong>Website:</strong> \'.$_imd_portfolio_website_output.\'</li>
完整代码:
function imd_portfolio_meta_box() {
global $post;
// get the custom field values as an array
$values = get_post_custom( $post->ID );
// extract the members of the $values array to their own variables (which you can see below, in the HTML code)
extract( $values, EXTR_SKIP );
// escape the output, just in case
$allowed_html = array(
\'a\' => array(
\'href\' => array(),
\'title\' => array()
),
\'em\' => array(),
\'strong\' => array()
);
$_imd_portfolio_details_output = wp_kses($_imd_portfolio_details[0], $allowed_html);
$_imd_portfolio_client_output = wp_kses($_imd_portfolio_client[0], $allowed_html);
$_imd_portfolio_website_output = wp_kses($_imd_portfolio_website[0], $allowed_html);
$_imd_portfolio_quote_output = wp_kses($_imd_portfolio_quote[0], $allowed_html);
$output = \'<div class="review-box">
<ul class="review-box-list">
<li><strong>Details:</strong> \'.$_imd_portfolio_details_output.\'</li>
<li><strong>Client:</strong> \'.$_imd_portfolio_client_output.\'</li>
<li><strong>Website:</strong> \'.$_imd_portfolio_website_output.\'</li>
<li><strong>Quote:</strong>\'.$_imd_portfolio_quote_output.\'></li>
</ul>
</div>\';
return $output;
}
更新:问题已解决我已编辑代码;更改此行-
<li><strong>Website:</strong> \'.$_imd_portfolio_website_output.\'</li>
到该行-
<li><strong>Website:</strong><a href="http://\'.$_imd_portfolio_website_output.\'">\'.$_imd_portfolio_website_output.\'</a></li>
谢谢大家的帮助