How do I make my child theme re-apply the settings that were customised when its parent was active?

I gave a +1 to the @webtoure’s answer because it gives you the right direction, however I think it lacks some checks. First of all it does not check that the theme that’s being activated is a child theme, and does not check that the theme previously active is the parent theme of the child … Read more

WooCommerce: change display order of product short description and price [closed]

If you look at woocommerce/templates/content-single-product.php you’ll see that the product summary is constructed using hooks with different priorities. Here’s the relevant section: <?php /** * woocommerce_single_product_summary hook * * @hooked woocommerce_template_single_title – 5 * @hooked woocommerce_template_single_rating – 10 * @hooked woocommerce_template_single_price – 10 * @hooked woocommerce_template_single_excerpt – 20 * @hooked woocommerce_template_single_add_to_cart – 30 * @hooked … Read more

How to *remove* a parent theme page template from a child theme?

Overriding that template would be much easier than getting rid of it. Just the way logic goes. I make no claim it’s efficient idea (late here), but this would get it nuked from edit screen: add_action(‘admin_head-post.php’,’remove_template’); function remove_template() { global $wp_themes; get_themes(); $templates = &$wp_themes[‘Twenty Ten’][‘Template Files’]; $template = trailingslashit( TEMPLATEPATH ).’onecolumn-page.php’; $key = array_search($template, … Read more

Remove parent theme action in child

For removing an action hook you should use the same action name, callback name and the priority that was used to add a action in parent theme. And register it on init add_action( ‘init’, ‘remove_my_action’); function remove_my_action() { remove_action( ‘woocommerce_before_shop_loop’,’storefront_sorting_wrapper’,9 ); } Read about remove_action

remove_action on after_setup_theme not working from child theme

As @cybmeta already pointed out, you are too early with your removal. So you have to defer the actual removal, for instance like so: add_action( ‘after_setup_theme’, ‘wpdev_170663_remove_parent_theme_stuff’, 0 ); function wpdev_170663_remove_parent_theme_stuff() { remove_action( ‘after_setup_theme’, ‘et_pb_setup_theme’ ); }

How to add code to Header.php in a child theme?

I would hook into the wp_head action. I would place this in a plugin so as to abstract it from your presentation layer. This allows for scalability and changing of themes. This also prevents any analytics collateral damage if a step is missed in migration from one theme to the next. add_action(‘wp_head’, ‘wpse_43672_wp_head’); function wpse_43672_wp_head(){ … Read more

Versioning @import of parent theme’s style.css

You don’t have to use @import. It’s best not to, actually. Using an enqueued approach is probably better all around. Here’s the relevant part of twentythirteen’s code: function twentythirteen_scripts_styles() { … // Loads our main stylesheet. wp_enqueue_style( ‘twentythirteen-style’, get_stylesheet_uri(), array(), ‘2013-07-18’ ); … } add_action( ‘wp_enqueue_scripts’, ‘twentythirteen_scripts_styles’ ); Here’s what you do in your code: … Read more

How to override parent functions in child themes?

You should run the code after theme setup. function osu_twentyten_continue_reading_link() { return ‘ <a href=”‘. get_permalink() . ‘”>’ . __( ‘Read on <span class=”meta-nav”>&rarr;</span>’, ‘twentyten-child’ ) . ‘</a>’; } function osu_twentyten_auto_excerpt_more( $more ) { return ‘ &hellip;’ . osu_twentyten_continue_reading_link(); } function my_child_theme_setup() { remove_filter( ‘excerpt_more’, ‘twentyten_auto_excerpt_more’ ); add_filter( ‘excerpt_more’, ‘osu_twentyten_auto_excerpt_more’ ); } add_action( ‘after_setup_theme’, ‘my_child_theme_setup’ … Read more

How do I dequeue a parent theme’s CSS file?

I want to use @import instead so I can override styles more easily Simply. Don’t. Do. That. You simply jump into the same hook and then deregister/dequeue the styles/scripts and throw in your custom ones. function PREFIX_remove_scripts() { wp_dequeue_style( ‘screen’ ); wp_deregister_style( ‘screen’ ); wp_dequeue_script( ‘site’ ); wp_deregister_script( ‘site’ ); // Now register your styles … Read more