Support » Developing with WordPress » Duplicate Shortcode into Child Theme

  • tr33t0p55

    (@tr33t0p55)


    Hello All,

    Question: Can I duplicate a parent theme’s plugin shortcode into a child theme and essentially in my case change a small bit of logic and UI output content? (plugin: post slider)

    In my case I just want to alter the UI output based on Custom Post Type (which plugin supports already…ie just going to fork a small bit of logic and output. I quickly altered the parent shortcode for proof of concept and it worked but I want to ensure to follow best practices and not change parent theme files.

    I dont want to create a new plugin just to alter some simple UI output if I dont have to. I am a dev but pretty new to WP dev.

    I’ve read a post where a developer removed the parent shortcode using child theme function.js file and then added in his (duplicated and altered) shortcode. It was pretty much suedo code so not much specific help.

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator t-p

    (@t-p)

    Can I duplicate a parent theme’s plugin shortcode into a…

    I recommend asking at your theme’s support so the theme’s developers and support community can help you with this.

    Moderator bcworkz

    (@bcworkz)

    Your child’s shortcode handler function must have a new, unique name (see below for one exception). I think you can add your function using the same shortcode handle, but I’ve not verified. Try it and see 🙂 If it fails, you’ll need a new handle as well.

    We normally cannot override previously declared function names in PHP, hence the need for a new unique name. However, if the function declarations are set up as “pluggable”, then you would be able to override using the same name. Pluggable declarations begin with code that looks something like:
    if ( ! function_exists( 'shortcode_handler_name' ) ) :

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.