Parse error: syntax error, unexpected (in WP plugin) PHP

1.5k Views Asked by At

I'm trying to add a button Read more, but when adding a button code in DIV, an error appears, and the plugin does not work. Tell me where the error is?

Parse error: syntax error, unexpected 'href' (T_STRING) in /****/public_html/wp-content/plugins/page-list/page-list.php on line 351

/*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>';

Thanks!

2

There are 2 best solutions below

1
On BEST ANSWER

There are a couple of things wrong with your code. The /*BEFORE */ code is broken because of that ' at the end, but you want to get the /*AFTER */ code working so let's focus on that:

$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?

I think what you're looking for is this:

$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>';
0
On

You have several errors.
There are errors in the use of the " and '
When you invoke the esc_attr () function, you are passing invalid arguments.