1

I'm trying to get a shortcode function (newStuff) to display inside of another function (oldStuff), but I'm running into trouble. Both shortCode functions are listed below, as well as what I've tried. Can someone please help me get the "newStuff" function displaying inside of the "oldStuff" function?

Thanks!

Current Functions

function newStuff(){
return '
only raw html is in this function
';
}
add_shortcode('new', 'newStuff');

function oldStuff(){
return '
only raw html is in this function
';
}
add_shortcode('old', 'oldStuff');

I tried including the short code, but it didn't work

function oldStuff(){
return '
[new]
only raw html is in this function
';
}
add_shortcode('old', 'oldStuff');

I tried including the function, but it didn't work

function oldStuff(){
return '
echo newStuff();
only raw html is in this function
';
}
add_shortcode('old', 'oldStuff');
6

You should use do_shortcode() function in both strings you are returning it will execute the shortcodes in the string.

function oldStuff(){
    return do_shortcode('
        [new]
        only raw html is in this function
    ');
}
add_shortcode('old', 'oldStuff');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.