将自定义字段值显示为超链接

时间:2011-08-04 作者:Sledge81

使用以下代码显示自定义字段值,如何将其自动设置为超链接?

<?php
  $custom_fields = get_post_custom($post_id); //Current post id
  $my_custom_field = $custom_fields[\'website\']; //key name
  foreach ( $my_custom_field as $key => $value )
  echo $key . " => " . $value . "<br />";
?>
当前,如果网站值设置为http://www.abc.com 然后它会显示http://www.abc.com 相反,我想让它显示为单击此处,而不是超链接。

1 个回复
最合适的回答,由SO网友:Scott 整理而成
<?php
  $custom_fields = get_post_custom($post_id); //Current post id
  $my_custom_field = $custom_fields[\'website\']; //key name
  foreach ( $my_custom_field as $key => $value )
  echo $key . " => <a href=\'" . $value . "\'>Click Here</a><br />";
?>
结束

相关推荐