全球主机交流论坛

标题: 求助解决Wordpress无法运行自定义新的code标签问题 [打印本页]

作者: GMT    时间: 2012-9-6 19:40
标题: 求助解决Wordpress无法运行自定义新的code标签问题
为了添加漂亮的代码框,这样在wordpress的function.php加入了以下代码:
  1. function codequote( $atts, $content = null ) {
  2.         extract(shortcode_atts(array(
  3.                 'float' => 'none',
  4.         ), $atts));
  5.    return '<style type="text/css">
  6.        .codequote{
  7.         省略代码...;}
  8.         .codequote:after{       
  9.         省略代码...;}
  10.         a:hover{text-decoration:none;}
  11.                 </style>
  12. <div class="codequote ' . $float . '">' . $content . '</div>';
  13. }
  14. add_shortcode('code', 'codequote');
复制代码
输出结果是syntax error, unexpected T_CONSTANT_ENCAPSED_STRING 错误信息,错误行数是指向“<div class="codequote ' . $float . '">' . $content . '</div>';”

如果去掉 .codequote:after 伪元素,就正常显示代码框了。

是因为return下codequote不能重复吗?还是错误行数的问题?




欢迎光临 全球主机交流论坛 (https://443502.xyz/) Powered by Discuz! X3.4