In below example, I wrapped

Error: Contact form not found.

inside another shortcode [myform]. So, when posting, just use [myform] istead:

function wrapthecode() {
    return do_shortcode('

Error: Contact form not found.

'); } add_shortcode( 'myform', 'wrapthecode' );

But how to append variable ID on the new shortcode?

Means [myform id="33"] is

Error: Contact form not found.

and [myform id="34"] is

Error: Contact form not found.

1
1

You need to get the attributes of the shortcode, which is quite simple and documented in the add_shortcode() examples:

function wrapthecode( $attr ) {
    if( empty( $attr['id'] ) )
        return 'No ID given.';

    return do_shortcode('

Error: Contact form not found.

. '"]'); } add_shortcode( 'myform', 'wrapthecode' );

Tags:

Leave a Reply

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