0

I have found only a small handful of posts from around the internet regarding Shortcodes and allowing them to work / execute within Admin Pages.

So, I have made several admin pages in Wordpress, and one of them requires me to add a shortcode from one of the other plugins.

I have found this solution which according to the comments it works: do_shortcode() within Admin Page

However, the example in the answer uses [example] as the shortcode, the shortcode I am trying to use is [customcont form=3] If you notice, there is a space in my shortcode which is what puzzled me.

Because of that I'm now struggling how to incorporate that into the example that is on that thread??

This is not a duplicate question, I'm asking how to add my shortcode with a space into the example provided.

Thank you in advance!

5
  • codex.wordpress.org/Function_Reference/do_shortcode. In the example you saw they call the shortcode function directly
    – Tomás Cot
    Commented Sep 23, 2014 at 12:59
  • Thank You, however, They are avoiding the do_shortcode in the example I provided... the chosen answer states that and provides an alternative?
    – Jonathan
    Commented Sep 23, 2014 at 13:35
  • same question with the same answer. shortcodes are for front end you might or might not be able to get what you want by directly calling their core function to generate the info on the admin side Commented Sep 23, 2014 at 13:54
  • 1
    I reopened your question. And there is now a big but here: Remove all that extra boldness and the SHOUTING. Then edit your title to reflect the "space in shortcode" part. And for future questions: Do not SHOUT in questions, comments and answers. Got that?
    – kaiser
    Commented Sep 24, 2014 at 18:27
  • I did not intend to shout, i was highlighting the areas that point out it is not a duplicate answer - my bad. Edits done. Thank You.
    – Jonathan
    Commented Sep 25, 2014 at 3:49

1 Answer 1

0

there isn't an "space" in the Shortcode-Name. What you have, is an shortcode called "customcont", that is providing an Parameter called "form".

So this is, how it should work:

function example_shortcode( $atts = array(), $content = '' )
{
    extract( 
        shortcode_atts( 
            array (
                'form' => 0,
            ), 
            $atts 
       )
   );

    return 'FORM TO DISPLAY IS #'.$form;
}
add_shortcode( 'customcont', 'example_shortcode' );

With the $form Variable you can Access the Number of the form to Display, in your case the "3".

1
  • Perfect! thank you so much Lippoliv! I quickly just tried this out and it executes perfectly. Thank You!
    – Jonathan
    Commented Sep 25, 2014 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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