[英]PHP : echo wordpress comments link and comments number on a href
I tried the search but did not get the complete answer to my question. 我尝试了搜索,但没有得到我问题的完整答案。 I build a WordPress website with redux framework options panel and need switch on/off the option to hide meta info on WordPress posts. 我使用redux框架选项面板构建了一个WordPress网站,并且需要打开/关闭该选项以隐藏WordPress帖子上的元信息。
I got already post date&author post link working but have a problem with echo href on WordPress comments link. 我已经可以发布日期和作者发布链接,但是WordPress评论链接上的echo href有问题。
original code looks like this 原始代码看起来像这样
<i class="far fa-comment"></i> <a href="<?php comments_link(); ?>"><?php comments_number('No comments', '1 comment', '% comments'); ?></a>
but I need to echo it inside PHP code 但我需要在PHP代码中回显它
<?php global $wpdf;
if( $wpdf['text-muted']){
//Do Something if switch is on(i.e - true)
if(esc_html($wpdf['text-muted'] == '1')) {
echo '<i class="far fa-calendar-alt"></i> ';
echo wpdf_post_date();
echo ' | <i class="far fa-user"></i> ';
echo the_author_posts_link();
echo ' | <i class="far fa-comment"></i> ';
}
}
?>
应该是这样的:
echo '<i class="far fa-comment"></i> <a href="'.get_comments_link( $post_ID ).'">'.comments_number("No comments", "1 comment", "% comments").'</a>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.