0
votes

I have a coruscate premium theme. I have created a child theme for future protection. I want to override a function in file parent-theme/framework/shortcodes/widgets.php which is defined as:

function wt_shortcode_recent_posts($atts) {
  //some code here
}
add_shortcode('wt_recent_posts', 'wt_shortcode_recent_posts');

Now, In my functions.php of child theme, I tried to override the function as:

function wt_shortcode_recent_posts($atts) {
   //some modified code here
}

I have also tried making a file to identical directory as child-theme/framework/shortcodes/widgets.php. It also doesn't work.

What is the correct way to override those functions or php files in wordpress child theme.

1

1 Answers

1
votes

You have to override the shortcode function. Add the folowing to your child theme functions.php

function some_new_shortcoe_function($atts) {
    // New shortcode code here
}

remove_shortcode('wt_recent_posts');   
add_shortcode('wt_recent_posts', 'some_new_shortcode_function');