Can't override map shortcode

Dear support,

I need help in overriding the map shortcode in the Betheme Child theme but it does not reflect on the changes. Below is the snippet of the code in the functions.php on the child theme. Am i doing correctly? Btw, the Betheme Child is activated already.

add_action( 'after_setup_theme', 'mfnch_textdomain' );

function mfnch_textdomain() {
load_child_theme_textdomain( 'betheme', get_stylesheet_directory() . '/languages' );
    load_child_theme_textdomain( 'mfn-opts', get_stylesheet_directory() . '/languages' );
}

add_action( 'init', 'calling_child_theme_setup' );

/* ---------------------------------------------------------------------------
* Map [map] [/map]
* --------------------------------------------------------------------------- */

function calling_child_theme_setup() {

    remove_shortcode( 'map');
    add_shortcode( 'map', 'my_sc_map' );

}

function my_sc_map( $attr, $content = null ) {
// my modified codes
}

Comments

  • Hi,

    what you ask for, requires files customization what in reference to Item Support Policy is not allowed. So if you want to modify files and don’t know how, you should contact with your web developer. The policy says:

    Item support does not include services to modify or extend the item beyond the original features, style and functionality described on the item page. For customization services that will help you tailor the item to your specific requirements, we recommend contacting the author to see if they privately offer paid customisation services or checking out the great service providers on Envato Studio.

    Best regards,
    Muffin Group team
  • Dear support,

    I'm not asking for you to help me modify my code. Wordpress's remove_shortcode is a common thing to do for web development. I'm just asking for your guidance, since you are the developer for Betheme, how should i go about in implementing the remove_shorcode. I have tried add_action for 'init' and  'after_setup_theme, but it does not seem to override your existing shortcode function.

    Is that too much to ask?
  • You do not have to use 'remove shortcode'
    You only need to overwrite the function "sc_map"

  • Will my modified 'sc_map' function returned to default if i perform any future updates to Betheme?
  • Yes, you should be using a child theme.
  • To those who needs to override parent's shortcode function, this article below is where i found my answer using method 1.


    Solution: I just declare the same function name as 'sc_map' in functions.php on my child-theme to override the parent theme's function. 

    Hope it helps someone out there.
Sign In or Register to comment.