从代码行中删除一个href

Remove a href from code line

本文关键字:一个 href 代码 删除      更新时间:2023-09-26

我有一个wordpress主题,我想稍微编辑一下。在这个主题中,我想从我的html中删除一个包含图像的href链接。BTF,我是编码新手,但主题支持没有回答。据我所知,它是用php和js生成的。

这是html

 <a href="" class="thumb full_image" ind="0"><img src="http://www.example.com/wp-content/uploads/2015/08/DSC06676print-21x15.-900x1323.jpg" class="attachment-gallery-scroll" ind="0"></a>

这是生成html的代码行我想是的…

$html = sprintf( '<li class="fade" data-url-id="%s"><a %s href="%s" class="%s full_image" title="%s">%s</a></li>',$attachment_id, $rel, $image_link, $image_class, $image_caption, $image );
echo apply_filters( 'easy_image_gallery_html', $html, $rel, $image_link, $image_class, $image_caption, $image, $attachment_id, $post->ID );

最后,我想要像<img src="http://www.example.com/wp-content/uploads/2015/08/DSC06676print-21x15.-900x1323.jpg" class="attachment-gallery-scroll" ind="0">这样的img line没有href,或者img line在前面,href在后面。

任何想法?这可能吗?我会为每一个答案感到高兴,这将使我更接近解决方案。谢谢! !

你现在看到的是:

$html = sprintf( '<li class="fade" data-url-id="%s">
<a %s href="%s" class="%s full_image" title="%s">%s</a></li>',
$attachment_id, $rel, $image_link, $image_class, $image_caption, $image );

这是你所需要的,基于你所描述的:

$html = sprintf( '<li class="fade" data-url-id="%s">%s</li>',
$attachment_id, $image);

[EDIT]sprintf$html调用后,有echoapply_filters函数,我不知道确切的角色,因为它隐藏在你没有显示的其余代码中。在进行重大更改之前,值得考虑它的输出内容!