我继承了另一位开发人员的作品,这是一个用 WP Bakery Page Builder 制作的网站,我必须修复一些设计问题。
问题是其他开发人员添加了一些我在后端找不到的自定义 CSS 代码。
它在index.php中生成为inlince css。看起来像这样。
<noscript><style type="text/css">body .wpex-vc-row-stretched, body .vc_row-o-full-height { visibility: visible; }</style></noscript><style type="text/css" data-type="vc_shortcodes-custom-css">.vc_custom_1530389595419{padding-top: 5% !important;padding-bottom: 5% !important;}</style>
我对这些 vc_custom_* 类有问题,我想将它们全部删除。
你们能帮我找到这些神秘的CSS吗?
非常感谢。
您可以使用条件标签来定位需要删除样式的特定页面。您可以使用 is_page() 来定位页面页面(而不是其他帖子类型)并传递页面 ID、slug、标题或不传递任何参数来定位任何页面。
function wpse_217881_remove_scripts() {
// Check for the page you want to target
if ( is_page( 'About Me And Joe' ) ) {
// Remove Styles
wp_dequeue_style( 'parent-style' );
wp_dequeue_style( 'child-style' );
wp_dequeue_style( 'parent-style-css' );
wp_deregister_style( 'parent-style' );
wp_deregister_style( 'child-style' );
wp_deregister_style( 'parent-style-css' );
}
}
我假设您已经是,但明确地说,您应该调用从操作挂钩中出列/取消注册样式的函数 - 在本例中为 wp_enqueue_scripts。
尽管有这个名字,但它用于对脚本和样式进行排队
天啊。我爱你,@philler82
您刚刚帮我解决了过去两个小时以来我一直试图解决的问题。
谢谢!