0

I've requirement to use multiple values for Shortcode.

Currently I'm adding 2 separate shortcodes for the same

e.g.

[wpcode id="2658"]

[wpdiscuz_comments]

Is there a way to use single Shortcode and add multiple values ?

1
  • What problem does doing this solve? What you've written doesn't make sense, can you describe the original problem? Is there any particular reason not to use 2 shortcodes? I edited out the references to widgets as widgets are not shortcodes, and shortcodes are not widgets.
    – Tom J Nowell
    Commented May 9, 2023 at 12:22

1 Answer 1

1

You can combine these two shortcodes into one by using a custom shortcode that includes both of them:

function custom_shortcode() {
    $output = '';

    // Get the wpcode shortcode output
    $wpcode_output = do_shortcode('[wpcode id="2658"]');

    // Get the wpdiscuz_comments shortcode output
    $wpdiscuz_output = do_shortcode('[wpdiscuz_comments]');

    // Combine the two outputs into a single output
    $output .= $wpcode_output . $wpdiscuz_output;

    // Return the combined output
    return $output;
}
add_shortcode('custom_shortcode', 'custom_shortcode');

Please note: The way to pass values to a shortcode can vary depending on the specific shortcode and the plugin or theme that provides it.

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