I want to add the next line to one of files of woocommerce in concrete: wp-content\plugins\woocommerce\templates\archive-product.php
<div class="breadcrumps-header"><?php if ( function_exists( 'yoast_breadcrumb' ) ) {yoast_breadcrumb();} ?></div>
But in the next update of Woocommerce I'll loose the modification. How can I do it to add like plugin chlid?
If you look at that file (https://github.com/woocommerce/woocommerce/blob/v2.2.3/templates/archive-product.php), you'll see a number of different actions you can use depending on where you want that content inserted.
For example, near the top there's this:
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
The comment shows that woocommerce's own breadcrumbs are hooked to this action with a priority of 20.
If you wanted your code to appear after this, you should be able to add something like the following to your theme's functions.php
(or somewhere else):
add_action('woocommerce_before_main_content', function() { ?>
<div class="breadcrumps-header">
<?php if ( function_exists( 'yoast_breadcrumb' ) ) {yoast_breadcrumb();} ?>
</div>
<?php });
25
is the priority, ensuring your code will execute after woocommerce's woocommerce_breadcrumb
function.
There are lots of other do_action
s in that script, so choose the one closest to where you want your code and you should get what you need with a little experimentation.