使用标题判断对应的点击广告显示:制造热门人数咨询
- 工作日记
- 1天前
- 36热度
- 0评论
功能:
在第一张图片下面显示点击按钮和多人咨询,并增加相应的关键词随机显示。
显示效果:

代码:
<!-- 留咨按钮 -->
<style>
.custom-btn-wrap {
text-align: center;
margin: 30px 0;
}
/* 顶部咨询状态 */
.consult-status {
display: inline-flex;
align-items: center;
font-size: 18px;
color: #FFB400;
margin-bottom: 20px;
font-weight: bold;
width: 100%; /* 独占一行 */
justify-content: center; /* 居中显示 */
}
.consult-status .dot {
width: 14px;
height: 14px;
background: #0AC253;
border-radius: 50%;
margin-right: 8px;
}
/* 按钮样式 */
.custom-button {
display: inline-block;
padding: 10px 20px;
margin: 0 10px;
background: #2E7FFF;
color: #fff;
border-radius: 6px;
text-decoration: none;
font-size: 16px;
position: relative;
transition: 0.2s;
}
.custom-button:hover {
opacity: 0.9;
}
/* 二维码弹层 */
.qrcode-box {
display: none;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: -170px;
background: #fff;
padding: 10px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
z-index: 999;
}
.qrcode-box img {
width: 150px;
height: 150px;
}
.qr-btn:hover .qrcode-box {
display: block;
}
</style>
<!-- 留咨按钮 end-->
<!-- 留咨按钮 -->
<div id="liuzi_anniu" class="custom-btn-wrap" style="display: none;">
<!-- 顶部咨询状态:独立一行 -->
<div class="consult-status">
<span class="dot"></span>
4人正在咨询
</div>
<a target="_blank" onclick="open_suxiao();" class="custom-button">
在线咨询
</a>
<a href="javascript:void(0);" class="custom-button qr-btn">
添加客服微信
<div class="qrcode-box">
<img src="https://cdnpic.xxx.com/uploads/20240924/e39236eb0de6360e9a9e7b4135532673.png" alt="微信二维码" img-loaded="true">
</div>
</a>
</div>
<h1 class="entry-title">AI智能客服机器人:AI训练场助力企业提升客户服务效率 LLM客服</h1>
<div class="entry-content">
<p>在当今数字化时代,企业越来越依赖智能客服机器人来提升客户服务效率。AI训练场作为领先的人工智能平台,为企业提供了强大的工具和资源,帮助他们构建和优化智能客服解决方案。</p>
<p>智能客服机器人能够自动处理大量客户查询,提供即时响应,减少
人工客服的工作负担。通过AI训练场,企业可以轻松训练和部署定制化的智能客服机器人,满足不同业务需求。</p>
<img src="http://insight.xxx.com/wp-content/uploads/2025/12/263-e1764578522916.jpg" alt="智能客服机器人">
<p>AI训练场提供了丰富的训练数据和先进的机器学习算法,使企业能够不断提升智能客服机
<img src="http://insight.xxx.com/wp-content/uploads/2025/12/263-e1764578522916.jpg" alt="智能客服机器人">器人的性能和准确性。此外,平台还支持多语言和多渠道的客户服务,确保企业能够覆盖更广泛的客户群体。</p>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const titleEl = document.querySelector("h1.entry-title");
const keywords = ["AI智能客服", "机器人", "AI训练场","LLM客服","智能客服机器人","智能客服","AI客服"];
const liuziBtn = document.getElementById("liuzi_anniu");
if (!titleEl || !liuziBtn) return;
const titleText = titleEl.textContent;
// 判断标题是否包含任意关键词
const matched = keywords.some(keyword => titleText.includes(keyword));
if (matched) {
// 获取 entry-content 下的第一张图片
const entryContent = document.querySelector(".entry-content");
if (entryContent) {
const firstImg = entryContent.querySelector("img");
if (firstImg) {
// 将原按钮div移动到图片下面
firstImg.insertAdjacentElement('afterend', liuziBtn);
liuziBtn.style.display = "block";
// 生成 1~9 的随机数
const randomNum = Math.floor(Math.random() * 8) + 1;
// 替换“4人正在咨询”中的数字
const statusEl = liuziBtn.querySelector(".consult-status");
if (statusEl) {
statusEl.innerHTML = `<span class="dot"></span>${randomNum}人正在咨询${keywords[Math.floor(Math.random() * keywords.length)]}`;
}
}
}
} else {
// 如果标题不匹配,则隐藏按钮
liuziBtn.style.display = "none";
}
});
</script>
<!-- 留咨按钮 end-->对付wordpress懒加载的图片解决方案:
<!--自定义按钮 毛毛-->
<!-- 留咨按钮 -->
<style>
.custom-btn-wrap {
text-align: center;
margin: 30px 0;
}
/* 顶部咨询状态 */
.consult-status {
display: inline-flex;
align-items: center;
font-size: 18px;
color: #FFB400;
margin-bottom: 20px;
font-weight: bold;
width: 100%; /* 独占一行 */
justify-content: center; /* 居中显示 */
}
.consult-status .dot {
width: 14px;
height: 14px;
background: #0AC253;
border-radius: 50%;
margin-right: 8px;
}
/* 按钮样式 */
.custom-button {
display: inline-block;
padding: 10px 20px;
margin: 0 10px;
background: #2E7FFF;
color: #fff;
border-radius: 6px;
text-decoration: none;
font-size: 16px;
position: relative;
transition: 0.2s;
}
.custom-button:hover {
opacity: 0.9;
}
/* 二维码弹层 */
.qrcode-box {
display: none;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: -170px;
background: #fff;
padding: 10px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
z-index: 999;
}
.qrcode-box img {
width: 150px;
height: 150px;
}
.qr-btn:hover .qrcode-box {
display: block;
}
</style>
<!-- 留咨按钮 end-->
<!-- 留咨按钮 -->
<div id="liuzi_anniu" class="custom-btn-wrap" style="display: none;">
<!-- 顶部咨询状态:独立一行 -->
<div class="consult-status">
<span class="dot"></span>
4人正在咨询
</div>
<a href="javascript:void(0);" onclick="open_suxiao();" class="custom-button" style="color:#F6F7F9">在线咨询</a>
<a href="javascript:void(0);" class="custom-button qr-btn" style="color:#F6F7F9">添加客服微信
<div class="qrcode-box">
<img src="https://cdnpic.xxx.com/uploads/20251209/3ccdb5abf36c1568028f4e5d651b88bf.jpeg" style="max-width:none;" alt="微信二维码" img-loaded="true">
</div>
</a>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const titleEl = document.querySelector("h1.entry-title");
const keywords = [
"客服AI-Agent","客服系统","智能客服系统","智能客服","AI-Agent","LLM智能助理",
"AI客服","智能客服机器人","客服机器人","客服AI","AI客服系统","智能助手",
"语音客服","聊天机器人","LLM客服","AI客服助理","智能客服平台","智能客服Agent",
"AI训练场","客服培训","客服技能训练","智能客服训练","AI客服训练",
"聚合接待","语流机器人","语流Agent","客服外包","AIBPIO","BPO","LLM"
];
const liuziBtn = document.getElementById("liuzi_anniu");
if (!titleEl || !liuziBtn) return;
const titleText = titleEl.textContent;
// 找出所有匹配的关键词
const matchedKeywords = keywords.filter(kw => titleText.includes(kw));
if (matchedKeywords.length === 0) {
liuziBtn.style.display = "none";
return;
}
// 找 entry-content 下的第一个 wp-block-image
const firstImageBlock = document.querySelector(".entry-content .wp-block-image");
if (firstImageBlock) {
// 随机人数 1~9
const num = Math.floor(Math.random() * 9) + 1;
// 随机选择一个匹配的关键词
const matchedKeyword = matchedKeywords[Math.floor(Math.random() * matchedKeywords.length)];
const statusEl = liuziBtn.querySelector(".consult-status");
if (statusEl) {
statusEl.innerHTML = `<span class="dot"></span>${num}人正在咨询“${matchedKeyword}”相关解决方案`;
}
// 插入按钮到 wp-block-image 后面
firstImageBlock.insertAdjacentElement('afterend', liuziBtn);
liuziBtn.style.display = "block";
}
});
</script>
<!-- 留咨按钮 end-->
<!--自定义按钮 end-->