评论按钮wordpress



我正在编辑我的网站,以便添加评论按钮和查看评论按钮。

我调用了PHP wordpress函数,但不起作用。

我添加了这个按钮来代替Jetpack的sharedaddy模块。

这是代码:

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

php模块包括:

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

我认为这不会运行,因为我没有添加php wordpress函数的include。

有什么帮助吗?:-S

2个问题-您的语法不正确,因为您不应该使用PHP打开和关闭标记,您正在添加到变量$sharing_content,因此您的语法应该是;

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

当前帖子评论的第一个链接应该可以使用。然而,您的第二个链接根本不起作用,您只是将wp_list_comments();作为href值插入。wp_list_comments();将用于在模板中显示当前帖子的所有评论,而不是链接到它们。我建议你的href值应该是帖子的url,评论可以在那里查看;

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

最新更新