我希望邮件轮播上的人群能够将我发送到链接而不是帖子,并且过期时会自动删除。你应该知道我不是javascript的专家,我做的非常基本。
这是页面https://thecrescentbeachclub.com/events/upcoming-events/,我不知道是否有人可以帮我改进这个代码,或者可能创建另一个代码。
客户端添加带有特色图像的帖子,然后我们使用这个模块来显示轮播(他们喜欢现在显示的方式,你应该知道我没有做这个网站,所以很难改变客户的想法),当我添加了一个自动expirer,当事件结束时,帖子被删除,这里一切都很好。情况是,在我发送给你的链接上,我添加了下一个链接代码,因为我不想让人们去发帖,我希望他们转到外部链接。
jQuery(function($){
$('.qode-bct-posts .qode-bct-post').each(function(){
$(this).attr('id',$(this).index()+1);
});
$('.qode-bct-posts .qode-bct-post .qode-bct-post-image img').each(function(){
$(this).unwrap();
});
$('#1').wrap('<a style="width: 100%; display: inline-block; vertical-align: top;" href="https://www.eventbrite.com/e/easter-at-the-beach-buffet-brunch-tickets-58504343065" target="_blank" itemprop="url"></a>');
$('#2').wrap('<a style="width: 100%; display: inline-block; vertical-align: top;" href="#" target="_blank" itemprop="url"></a>');
$('#3').wrap('<a style="width: 100%; display: inline-block; vertical-align: top;" href="#" target="_blank" itemprop="url"></a>');
});
现在的问题是,当一个帖子被自动删除时,链接是错误的,例如,第一个帖子的ID为1,带有该链接,但是当expires消失时,现在ID为2的帖子的链接为1.我有手动更改链接,这是我们想要避免的。
有人可以帮助我使ID动态,所以当一个帖子到期并消失时其他人仍然会保持正确的链接吗?我希望我解释自己。
如果必须从html中删除特定的Id元素。将#1替换为您想要删除的内容。
$('.qode-bct-posts #1').parent().closest('a').remove();
您需要传递id以删除特定元素。
我找到了一个插件,它允许我添加一个外部链接到帖子,而不是帖子本身,所以我不需要使这个代码工作。我不想要因为当你添加更多插件时WordPress会变得疯狂,但客户很高兴,所以我很高兴。谢谢你的帮助。