0

Website theme overrides the plugin style, I'm using Cars4Rent child theme and chauffeur-booking-system plugin. I would like the original look and style of the booking plugin but the theme overrides the styles of the plugin. I tried using wp_dequeue_style(), wp_deregister_style() and wp_enqueue_style() and it reorders the style sheets but I still don't get the original design of the plugin. Both Cars4Rent theme and booking plugin uses JQuery and don't know if there's any conflict. I can share the website link to see the page source if anyone help. Im new to the wordpress and would appreciate the input of the experts. Thanks in advance

UPDATE

I have tried this with Twenty Twenty theme as well and the result is same. The below is the plugin php file. Could you please point me out on where the change needed please?

load_plugin_textdomain('chauffeur-booking-system',false,dirname(plugin_basename(FILE)).'/languages/');

require_once('include.php');

$Plugin=new CHBSPlugin(); $WooCommerce=new CHBSWooCommerce();

register_activation_hook(FILE,array($Plugin,'pluginActivation'));

add_action('init',array($Plugin,'init')); add_action('after_setup_theme',array($Plugin,'afterSetupTheme')); add_filter('woocommerce_locate_template',array($WooCommerce,'locateTemplate'),1,3);

$WidgetBookingForm=new CHBSWidgetBookingForm(); $WidgetBookingForm->register();

0

In a plugin, you have hook add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 ) to enqueue script and CSS. In this hook, there is third parameter $priority you can add the lowest priority to load that hook earlier in execution. So you have 2 options:

  • So if you do not have $priority added for plugin hook, it is 10. So you can add the higher priority for theme's hook. OR
  • You can add the less priority that 10 to plugin's hook.

This Priority option will work for you to load the script/css. for more information you can visit here: https://developer.wordpress.org/reference/functions/add_action/

Note**: Make sure plugin or theme update will not override this thing.

1
  • I have tried this with Twenty Twenty theme as well and the result is same. The plugin php file code is updated in the above post for the reference. Do I need to add the priority in the below add_action hook in the plugin? add_action('init',array($Plugin,'init')); add_action('after_setup_theme',array($Plugin,'afterSetupTheme'));
    – faz
    Jun 12 '20 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.