解析错误:语法错误,意外(在WP插件中)PHP

时间:2017-09-07 16:40:11

标签: php wordpress plugins syntax-error parse-error

我尝试添加按钮阅读更多内容,但在DIV中添加按钮代码时,会出现错误,并且该插件无效。告诉我错误在哪里?

  

解析错误:语法错误,意外' href' (T_STRING)在第351行的/****/public_html/wp-content/plugins/page-list/page-list.php中

/*BEFORE */
$list_pages_html .= '<div class="page-list-ext-item-content">'.$content.';                  

/*AFTER */
$list_pages_html .= '<div class="page-list-ext-item-content">'.$content.<p><a href="'.$link.'" title="'.esc_attr($page- rel="nofollow">post_title).'">Read More</a></p>'</div>';

谢谢!

2 个答案:

答案 0 :(得分:0)

您的代码存在一些问题。 /*BEFORE */代码在最后由于'而被破坏,但您希望/*AFTER */代码正常运行,所以让我们关注它:

$list_pages_html .= '<div class="page-list-ext-item-content">'.$content.<p>
// missing a ' here: --------------------------------------------------^^

<a href="'.$link.'" title="'.esc_attr($page- rel="nofollow">post_title).'">Read
// this doesn't belong here: ---------------^^^^^^^^^^^^^^^

 More</a></p>'</div>';
// Why is ---^ that ' there?

我认为您正在寻找的是:

$list_pages_html .= '<div class="page-list-ext-item-content">'.$content.'<p><a href="'.$link.'" title="'.esc_attr($page->post_title).'" rel="nofollow">Read More</a></p></div>';

答案 1 :(得分:0)

您有几个错误 使用'esc_attr ()时出错 当您调用<cfset validateRadio = { frmhs_rad1 = 0, frmhs_rad1 = 1, frmhs_rad2 = 0, frmhs_rad2 = 1, frmhs_rad2 = 2, frmhs_rad3 = 0, frmhs_rad3 = 1, frmhs_rad3 = 2 }> 函数时,您传递的是无效参数。