php - WordPress 图库删除 <br/>

标签 php css wordpress image-gallery

刚刚意识到默认情况下图库帖子类型有 <br style="clear: both">在每三张图片后的代码中添加标签(每 3 张,因为我在图库选项中选择了 3 列图片)。

我应该修改或添加到我的主题代码中的内容和位置,以防止这些标签被推送到我的画廊帖子,因为这会破坏平板电脑的响应式布局。

可能会在我的函数文件中添加一些 php。

我尝试在 <br /> 上使用 css要显示的图库帖子下的标签:无。这解决了部分问题 - 删除了换行符,但仍然弄乱了我在第 nth-child(2n) 上应用的 css。

任何建议或链接都​​会有很大帮助。

最佳答案

第一个选项:PHP FIX

您可以对主题文件夹中的 functions.php 文件执行一些操作,以确保删除整个图片库中的
标记或其实例。

add_filter( 'the_content', 'remove_br_gallery', 11, 2);
function remove_br_gallery($output) {
    return preg_replace('/<br style=(.*)>/mi', '', $output);
}

或者作为第二个选项:CSS FIX

style.css 在你的主题文件夹中添加:

.gallery br {
    display:none;
}

.gallery:after {
    visibility: hidden;
    display: block;
    font-size: 0;
    content: &quot; &quot;;
    clear: both;
    height: 0;
}

关于php - WordPress 图库删除 <br/>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29081908/

相关文章:

css - 如何用文本框均匀间隔文本?

php - 在 coldfusion 中反序列化 PHP 数组

php - 在 WooCommerce 管理员优惠券列表的新列中显示优惠券产生的总销售额

php - 在 Woocommerce 订单详细信息中显示产品类别名称

php - 移动身份验证器如何工作

php - 如何安装和使用 php 5.6 和 7.0, Arch Linux

php - 活字 : Category relationships

resources - 如何使用 Sproutcore 应用程序的 CSS 引用图像?

php - Composer 安装错误 - 输出不是 tty,输入不是 tty

css - 每个 Firebug - 不工作?