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.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.