0

Can I easily override plugin's templates and stylesheets in my child theme or does the plugin have to provide functionalities to do this?

I have overridden template files for some of the plugins in the past but some of them don't seem to work.

1

So long as a plugin / theme doesn't use the dreaded !important rule in their CSS files, you should be quite alright to include your own CSS, and over-ride their settings. However some very badly written plugins / themes do use the !important rule, which unfortunately makes it difficult or even impossible to over-ride their styling.

In situations like this, it's best to find what priority level and name they register their style sheet under, and unhook it via wp_dequeue_style( $handle );. It works the same as registering a stylesheet. In situations that require this, what I do is just de-queue their style sheet, copy it completely, and then make the changes I need accordingly. This is the most upgrade-friendly method of doing it, as it does not require you to modify their files directly.

  • 1
    Any reason for a downvote? – Hybrid Web Dev Nov 30 '14 at 3:43
  • Do you know how to override the php template of a plugin? I also need to do this along with the CSS. – user1448031 Nov 30 '14 at 6:41
  • Unless the plugin specifically uses the locate_template function, or otherwise uses a filter or an action hook, then no. In that case, modifying the plugins files directly would be your only option. However, if the plugin uses a built in wordpress function that has a hook built into it, you can tap in that way. A good example would be a plugin that uses the_content(). You can add a content filter to modify it's output that way. – Hybrid Web Dev Nov 30 '14 at 7:48
0

Write a function which uses wp_enqueue_style() to enqueue your stylesheet. Then hook your function to wp_enqueue_scripts using add_action(), making sure to use a priority (third argument) that is higher than the priority used by the plugin to enqueue its stylesheet.

Refs:

  • 1
    I also need to override the entire template php file, not just the stylesheet. I want to be able to add my own markup. Is there a way to do this? – user1448031 Nov 30 '14 at 5:24

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.