从代码行中删除href

时间:2015-08-26 23:34:32

标签: javascript php html wordpress

我有一个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 );

最后,我希望在没有href的情况下使用<img src="http://www.example.com/wp-content/uploads/2015/08/DSC06676print-21x15.-900x1323.jpg" class="attachment-gallery-scroll" ind="0">这样的img行,或者首先使用img行,然后使用href第二行。

有什么想法吗?可能吗?对于能让我更接近解决方案的每一个答案都会感到高兴。谢谢!

1 个答案:

答案 0 :(得分:1)

这就是你现在所拥有的:

$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);

[编辑] sprintf$html调用后,echo的{​​{1}}函数我不知道确切的角色,因为它隐藏在您未显示的其余代码中。在做出重大改变之前,值得考虑它的输出!