我有一个父主题调用函数woc_register_cssjs
,然后使用其中的wp_register_style
开展业务,然后使用add_action('wp_enqueue_scripts', 'woc_register_cssjs');
此文档的位置为theme/admin/theme-functions.php
我的问题是我似乎无法删除此脚本添加的css
文档 - 我创建了一个子主题,我想覆盖css文档。
在我的孩子主题function.php
中,我实现了以下功能,但它不起作用,而且父css文档仍在加载 - 为什么?
代码:
<?php
// Remove Perent Styles
function remove_css()
{
wp_deregister_style('layout.css');
}
add_action('wp_enqueue_scripts', 'remove_css', 100);
?>
主题函数 - 父级:
/*-----------------------------------------------------------------------------------*/
/* Register Scripts and CSS */
/*-----------------------------------------------------------------------------------*/
function woc_register_cssjs() {
//Register Scripts
wp_register_script('imagesloaded', get_template_directory_uri() . '/js/imagesloaded.pkgd.min.js', 'jquery', '1.0', false);
wp_register_script('customSelect', get_template_directory_uri() . '/js/jquery.customSelect.min.js', 'jquery', '1.0', false);
wp_register_script('wocSelect', get_template_directory_uri() . '/js/woc.select.js', 'jquery', '1.0', false);
wp_register_script('waypoints', get_template_directory_uri() . '/js/waypoints.min.js', 'jquery', '1.0', true);
wp_register_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', 'jquery', '1.0', true);
wp_register_script('retina', get_template_directory_uri() . '/js/retina.js', 'jquery', '1.0', true);
wp_register_script('mobileMenu', get_template_directory_uri() . '/js/woc.mobile.menu.js', 'jquery', '1.0', true);
wp_register_script('fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', 'jquery', '1.0', true);
wp_register_script('touchEffects', get_template_directory_uri() . '/js/toucheffects.js', 'jquery', '1.0', true);
wp_register_script('modernizer', get_template_directory_uri() . '/js/modernizr.custom.js', 'jquery', '1.0', true);
wp_register_script('menu', get_template_directory_uri() . '/js/woc.tooltipmenu.min.js', 'jquery', '1.0', true);
wp_register_script('isotope', get_template_directory_uri() . '/js/jquery.isotope.min.js', 'jquery', '1.1', true);
wp_register_script('isotope_sloppy_masonry', get_template_directory_uri() . '/js/jquery.isotope.sloppy-masonry.min.js', 'jquery', '1.0', true);
wp_register_script('shiv', get_template_directory_uri().'/js/html5.js', 'jquery', '1.0', true);
wp_register_script('base', get_template_directory_uri() . '/js/base.js', 'jquery', '1.0', true);
wp_register_script('woc_woocommerce', get_template_directory_uri() . '/js/woc.woocommerce.js', 'jquery', '1.0', true);
wp_register_script('gmaps', 'http://maps.google.com/maps/api/js?sensor=false', '', '1.0', false);
wp_register_script('validationEngine', get_template_directory_uri() . '/js/jquery.validationEngine.js', 'jquery', '1.0', true);
wp_register_script('cycle', get_template_directory_uri() . '/js/jquery.cycle.lite.js', 'jquery', '1.0', true);
// Register Styles
wp_register_style('base', get_template_directory_uri() . '/css/base.css', '', '', 'screen, projection');
wp_register_style('framework', get_template_directory_uri() . '/css/responsive-gs-12col.css', '', '', 'screen, projection');
wp_register_style('ie', get_template_directory_uri() . '/css/ie.css', '', '', 'screen, projection');
wp_register_style('layout', get_template_directory_uri() . '/css/layout.css', '', '', 'screen, projection');
wp_register_style('dropdowns', get_template_directory_uri() . '/css/woc-dropdowns.css', '', '', 'screen, projection');
wp_register_style('comments', get_template_directory_uri() . '/css/comments.css', '', '', 'screen, projection');
wp_register_style('flexslider', get_template_directory_uri() . '/css/flexslider.css', '', '', 'screen, projection');
wp_register_style('flexsliderNav', get_template_directory_uri() . '/css/flexslider-nav.css', '', '', 'screen, projection');
wp_register_style('fontawesome', get_template_directory_uri() . '/css/font-awesome.css', '', '', 'screen, projection');
wp_register_style('animate', get_template_directory_uri() . '/css/animate.min.css', '', '', 'screen, projection');
wp_register_style('isotope', get_template_directory_uri() . '/css/isotope.css', '', '', 'screen, projection');
wp_register_style('portfolio', get_template_directory_uri() . '/css/woc-portfolio.css', '', '', 'screen, projection');
wp_register_style('woocommerce', get_template_directory_uri() . '/css/woc-woocommerce.css', '', '', 'screen, projection');
wp_register_style('modal', get_template_directory_uri() . '/css/ct-modal-overlay.css', '', '', 'screen, projection');
wp_register_style('validationEngine', get_template_directory_uri() . '/css/validationEngine.jquery.css', '', '', 'screen, projection');
wp_register_style('pageBuilder', get_template_directory_uri() . '/css/page-builder-blocks.css', '', '', 'screen, projection');
}
add_action('wp_enqueue_scripts', 'woc_register_cssjs');
function woc_init_scripts() {
// Enqueue Styles
wp_enqueue_style('base');
wp_enqueue_style('framework');
wp_enqueue_style('ie');
wp_enqueue_style('layout');
wp_enqueue_style('dropdowns');
wp_enqueue_style('comments');
wp_enqueue_style('flexslider');
wp_enqueue_style('flexsliderNav');
wp_enqueue_style('fontawesome');
wp_enqueue_style('animate');
wp_enqueue_style('isotope');
wp_enqueue_style('portfolio');
wp_enqueue_style('pageBuilder');
wp_enqueue_style('validationEngine');
wp_enqueue_style('modal');
// Enqueue Scripts
wp_enqueue_script('imagesloaded');
wp_enqueue_script('underscore');
wp_enqueue_script('waypoints');
wp_enqueue_script('flexslider');
wp_enqueue_script('retina');
wp_enqueue_script('mobileMenu');
wp_enqueue_script('fitvids');
wp_enqueue_script('modernizer');
wp_enqueue_script('touchEffects');
wp_enqueue_script('menu');
wp_enqueue_script('isotope');
wp_enqueue_script('isotope_sloppy_masonry');
wp_enqueue_script('gmaps');
wp_enqueue_script('customSelect');
wp_enqueue_script('wocSelect');
wp_enqueue_script('shiv');
wp_enqueue_script('validationEngine');
wp_enqueue_script('cycle');
wp_enqueue_script('base');
if(is_page_template('template-contact.php')) {
}
if (is_singular()) {
wp_enqueue_script( "comment-reply" );
}
//script globals
$woc_script_global = array(
'site_url' => site_url(),
'template_url' => get_template_directory_uri(),
'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ));
wp_localize_script('base', 'woc_global', $woc_script_global);
if (is_plugin_active('woocommerce/woocommerce.php')) {
wp_enqueue_style('woocommerce');
wp_enqueue_script('woc_woocommerce');
}
}
add_action('wp_enqueue_scripts', 'woc_init_scripts');
答案 0 :(得分:1)
尝试以下方法:
wp_deregister_style( 'layout' );