子比主题添加评论链接填写框[已实装]

实用功能,本文来自转载,在此记录一下,免得以后找不到

修改 comments.php 文件

文件位置 wp-content/themes/zibll/template/comments.php

搜索 邮箱 找到评论区填写框位置,代码添加位置如图所示。

$o_t1 = $require_name_email ? '(可不填)' : '';

//评论区的网址填写框
                                        echo '<li class="line-form">';
                                        echo '<input type="text" name="url" class="line-form-input" tabindex="3" value="' . esc_attr($comment_author_url) . '" placeholder="">';
                                        echo '<div class="scale-placeholder">网址' . $o_t1 . '</div>';
                                        echo '<div class="abs-right muted-color"><i class="fa fa-fw fa-sitemap"></i></div>';
                                        echo '<i class="line-form-line"></i>';
                                        echo '</li>';
图片[1]-子比主题添加评论链接填写框[已实装]-淇云博客-专注于IT技术分享

修改 zib-comments-list.php 文件

文件位置 /wp-content/themes/zibll/inc/functions/zib-comments-list.php

找到 zib_get_comments_user_name 函数,修改为以下内容。

// 初始化用户名称(用户或访客)
    $user_name = $user_name ? $user_name : '<b class="mr6">' . $comment->comment_author . '</b>';
    
    // 新增:处理评论作者URL和作者标签
    $author_url = get_comment_author_url($comment->comment_ID);
    if (!empty($author_url) && $author_url !== 'http://' && $author_url !== 'https://') {
        // 如果存在作者URL,添加外部链接
        $user_name = '<a target="_blank" href="' . esc_url($author_url) . '">' . $user_name . '</a>';
    }
图片[2]-子比主题添加评论链接填写框[已实装]-淇云博客-专注于IT技术分享

感谢您的来访,获取更多精彩文章请收藏本站。

© 版权声明
THE END
喜欢就支持一下吧
点赞29赞赏 分享
评论 共6条
头像
欢迎提交您的评论,共创文明良好交流环境,请勿提交违规言论!
提交
头像

昵称

取消
昵称表情代码图片快捷回复