Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$30
How to override Parent Theme Functions in Child Theme
- This WooTheme uses the WooCommerce plugin
- The parent theme declares several WooCommerce plugin functions overrides (to override the default plugin output)
So how can I override these parent functions for the child theme?. From my understanding, this is certainly possible if/where the parent theme functions are pluggable/conditional. But this WooTheme is not (by my understanding)
For example, the parent theme declares the following functions in its functions.php file to override the default plugin output ...
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
function woocommerce_output_related_products() {
woocommerce_related_products(3,3); // 3 products, 3 columns
}I obviously cannot redeclare this function in the child theme functions.php as the child theme code gets executed before the parent.
I hope someone can help.
This question has been answered.
TheLoneCuber | 12/12/11 at 7:28am
Edit
(5) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
12/12/11
7:31amPeter Michael says:But you can remove the filter and re-add it with a different function name.
- 12/12/11 7:32am
Peter Michael says:
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
function my_output_related_products() {
// Your Stuff Here
}
add_action( 'woocommerce_after_single_product_summary', 'my_output_related_products', 20);
- 12/13/11 12:26am
Peter Michael says:And? Any update?
- 12/12/11 7:32am
-

Last edited:
12/12/11
7:32amJerson Baguio says:this might help
function osu_twentyten_continue_reading_link() {
return ' <a href="'. get_permalink() . '">' . __( 'Read on <span class="meta-nav">→</span>', 'twentyten-child' ) . '</a>';
}
function osu_twentyten_auto_excerpt_more( $more ) {
return ' …' . 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' );
the code above if from this article
- 12/12/11 7:39am
Jerson Baguio says:here's the link from that article http://wordpress.stackexchange.com/questions/7557/how-to-override-parent-functions-in-child-themes
- 12/12/11 7:39am
-

Last edited:
12/12/11
7:34amFrancisco Javier Carazo Gil says:Hi,
As you can see in the reference:
Unlike style.css, the functions.php of a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to the parent’s functions.php. (Specifically, it is loaded right before the parent’s file.)
So, you will have to run your code after theme setup and:
1. Make new functions
2. Remove your filter and actions
3. Create new filter and actions with your new functions.
For example:
function osu_twentyten_continue_reading_link() {
return ' <a href="'. get_permalink() . '">' . __( 'Read on <span class="meta-nav">→</span>', 'twentyten-child' ) . '</a>';
}
function osu_twentyten_auto_excerpt_more( $more ) {
return ' …' . 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' );
- 12/12/11 7:35am
Francisco Javier Carazo Gil says:Jerson and me have seen this page: http://wordpress.stackexchange.com/questions/7557/how-to-override-parent-functions-in-child-themes
- 12/12/11 7:35am
-

Last edited:
12/12/11
7:35amJulio Potier says:Hello try this :
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
add_action( 'woocommerce_after_single_product_summary', 'my_woocommerce_output_related_products', 20);
function my_woocommerce_output_related_products() {
woocommerce_related_products(3,3); // 3 products, 3 columns
} -

Last edited:
12/12/11
8:18amRomel Apuya says:try this :
function remove_woocommerce_after_single_product_summary() {
remove_action('woocommerce_after_single_product_summary','woocommerce_related_products',20);
}
add_action('init','remove_woocommerce_after_single_product_summary');
function woocommerce_output_related_products() {
woocommerce_related_products(3,3); // 3 products, 3 columns
}
add_action('woocommerce_after_single_product_summary','woocommerce_output_related_products', 20);Previous versions of this answer: 12/12/11 at 7:55am | 12/12/11 at 8:18am
This question has expired.
Gabriel Reguly had additional discourse to offer.
Gabriel Reguly, TheLoneCuber voted on this question.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
