选择“孙子”
我有一个充满挑战的问题!
让我们看看三种可能的情况
情景1
场景2
场景3
或其他项目的数量将是未定义的。 我怎么能只选择第一个img进行“display:none;”?
我的猜测是我必须把.entry-content作为父母,但是如果我做一个img:first-child,它会将
作为父级,并且如果有更多的话,它将不显示所有图片。 这就是为什么应该像祖父一样:D如果我们必须使用其他语言而不是CSS,我当然是开放的。
使用纯CSS无法做到这一点,但它在jQuery中非常简单,你很可能已经在页面上加载了它:
jQuery(document).ready(function($){ $('.entry-content img').first().hide(); });
演示: http : //jsfiddle.net/pq7rwfv3/
在主题的functions.php中添加此function
function Remove_image_tags($content) { // for example above function getting data by paramets $content = "this is something with an in it."; $content = preg_replace("/]+\>/i", " ", $content); return $content; }
它会回来
this is something with an in it.