How To Extend Parent Theme Shortcode Into Child Theme In WordPress Or Extend Any Plugins Shortcode Into Theme File

Here we learn about how to extend parent theme shortcode into a child theme in WordPress or extend any plugins shortcode into the theme file.

Custom code copied and paste into your child theme’s functions.php file.

Here I have ‘site_icon_text’ shortcode into my parent theme.

<?php
add_action('init', 'remove_parent_no_icon_text');
function remove_parent_no_icon_text() { 
  // I remove shortcode of parent theme
  remove_shortcode( 'site_icon_text' );
  
  // Initialize child theme shortcode for changes into render
  add_shortcode( 'site_icon_text', 'myblog_extend_no_icon_text' );
}

function myblog_extend_no_icon_text() {
  // shortcode render here
}
?>

 

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories