Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comment button wordpress

I'm editing my website for add a comment button and view comments button.

I call the PHP wordpress function but don't work.

I'm adding the button in place of Jetpack sharedaddy module.

This is the code:

$sharing_content .='<a style="margin-left:2px; font-weight:bold;" class ="comentar" href="<?php comments_link(); ?>">Add a comment</a>';

$sharing_content .='<a style="margin-left:5px; font-weight:bold;" class ="comentar" href="<?php wp_list_comments(); ?>">View comments</a>';

The includes of the php module:

include_once dirname( __FILE__ ).'/sharing-sources.php';

I think that dont run because I have not added the include of the php wordpress function.

Any help? :-S

like image 510
Kiko Beats Avatar asked Apr 26 '26 23:04

Kiko Beats


1 Answers

2 issues - Your syntax is incorrect in that you shouldn't be using the PHP opening and closing tags, you are adding to the the variable $sharing_content so your syntax should be;

$sharing_content .='<a style="margin-left:2px; font-weight:bold;" class ="comentar" href="'. comments_link() .'">Add a comment</a>';

The first link to the comments for the current post should work. However, your second link won't work at all, you've just stuck wp_list_comments(); in as the href value. wp_list_comments(); would be used to display all the comments of the current post in a template, not to link to them. I'd suggest that your href value should be the post's url, the comments will be viewable there;

$sharing_content .= '<a style="margin-left:5px; font-weight:bold;" class ="comentar" href="'. the_permalink() .'">View comments</a>';
like image 116
McNab Avatar answered Apr 28 '26 11:04

McNab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!