I am trying to modify a part of code inside: themes / flatsome / inc / shortcodes / ux_products.php
I want to change this:
<a href="<?php echo get_the_permalink(); ?>">
For this
<a href="<?php echo get_the_permalink(); ?>" aria-label="<?php echo get_the_title(); ?>">
I have the same path and file inside the folder of my child theme but I can’t annul the main theme file.
I realized that there is another file that refers to the file I want to cancel: themes / flatsome / inc / init.php:
if (is_woocommerce_activated()) {
require get_template_directory() . '/inc/shortcodes/ux_products.php'; //File to annul
require get_template_directory() . '/inc/shortcodes/ux_products_list.php';
require get_template_directory() . '/inc/shortcodes/product_flip.php';
require get_template_directory() . '/inc/shortcodes/product_categories.php';
if(get_theme_mod('product_layout') == 'custom') {
require get_template_directory() . '/inc/shortcodes/custom-product.php';
}
}
How can I do this without having to modify the main theme (this works but it is not correct).
2
Answers
Can you try adding this to your child theme’s functions.php:
First you need copy the shortcode you need modify to your child theme.
Then you need to modify the child shortcode, function name :
to
Modify what you need:
to
And at the end of your child shortcode file, override all (or only needed) declared shortcodes, with your own function :
to
To override all shortcodes :
Finally in your function.php or ‘/inc/init.php’, you need require overrided shortcodes when wp_loaded :