我有个问题,我希望你们能帮我,因为我快疯了。无论如何,正如您所知,wordpress在标签中输出附加的图像。我需要他们作为背景图像css。这是我的代码;
<?php
$content = get_the_content();
$feat_image_url = wp_get_attachment_url( $post->ID, \'\' )[0];
$content = preg_replace("/<img[^>]+\\>/i", "<div class=\'single-
parallax-image\' style=\'background-image:url(".$feat_image_url.")\'></div>", $content);
$content = apply_filters(\'the_content\', $content);
$content = str_replace(\']]>\', \']]>\', $content);
echo $content;
?>
如您所见,我需要将img标记替换为
<div class=\'single-parallax-image\' style=\'background-image:url(".$feat_image_url.")\'></div>
谢谢。。