How do I cleanly override a plugin’s CSS with a child theme?

If the plugins are correctly adding their styles via wp_enqueue_style, you simply need to dequeue them: function wpa_dequeue_style() { wp_dequeue_style( ‘plugin-style-handle’ ); } add_action( ‘wp_enqueue_scripts’, ‘wpa_dequeue_style’, 100 ); Whether or not this works depends on how and where the plugins are adding their styles, so there’s no absolute answer without knowing specific methods the plugins … Read more

A way to automatically install pages on theme install?

I got similiar situation where I needed to add page on theme activation and set it as homepage automatically. Here’s how I did it: add_action(‘after_setup_theme’, ‘mytheme_setup’); function mytheme_setup(){ if(get_option(‘page_on_front’)==’0′ && get_option(‘show_on_front’)==’posts’){ // Create homepage $homepage = array( ‘post_type’ => ‘page’, ‘post_title’ => ‘Home’, ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_author’ => 1 ); // Insert … Read more

Custom Image section in Customizer

So I did some research on the matter and I found a solution. Basically WordPress has this cool feature where you can call something called get_theme_mod so what I essentially did was add get_theme_mod inside my <img> src. So this is what I changed my <img> tag to after finding out about get_theme_mod: <img src=”https://wordpress.stackexchange.com/questions/215701/<?php … Read more

How to enqueue script if widget is displayed on page?

You should be able to call wp_enqueue_script() as part of your Widget output. Edit Quick-and-dirty, using the bare-bones Widgets API class example: <?php class wpse48337_Widget extends WP_Widget { public function __construct() { // widget actual processes } public function form( $instance ) { // outputs the options form on admin } public function update( $new_instance, … Read more