Title: problem with php and shortcodes
Last modified: August 19, 2016

---

# problem with php and shortcodes

 *  [ash_learner](https://wordpress.org/support/users/ash_learner/)
 * (@ash_learner)
 * [17 years ago](https://wordpress.org/support/topic/problem-with-php-and-shortcodes/)
 * HI ,
 * I am sure my problem is something really simple but I am still new to php and
   what code I use is “standing on the shoulders of giants”. I am slowly learning
   my way through it all.
 * But i am having a problem with using shortcodes.
 * you can view my code here: [http://pastie.org/509451](http://pastie.org/509451)
 * Basically I want to integrate a theme options page for a client that will let
   him add aweber optin forms on any page /post.
 * I set up the options page of the theme and its working. Everything works great
   except the shortcode part. It does not seem to parse the PHP and returns the 
   php itself rather than the values the php should create.
 * When I hardcode the form into a page it works fine pulling from the variables
   entered into the options page, but the shortcode does not.
 * The shortcode DOES print the form, but the PHP remains unparsed.
 * am hoping someone can see this and point me in the right direction I am sure 
   its something I am doing that only a novice would screw up.
 * Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [17 years ago](https://wordpress.org/support/topic/problem-with-php-and-shortcodes/#post-1104586)
 * Probably a bit obvious but did you remember to register the new shortcode using
   add_shortcode()?
 * [http://codex.wordpress.org/Shortcode_API](http://codex.wordpress.org/Shortcode_API)
 *  Thread Starter [ash_learner](https://wordpress.org/support/users/ash_learner/)
 * (@ash_learner)
 * [17 years ago](https://wordpress.org/support/topic/problem-with-php-and-shortcodes/#post-1104609)
 * Hi esmi,
 * Yes I did remember, thanks. The shortcode works in that it does return the form,
   but the forms values are populated by php which is not getting processed for 
   some reason. I have marked the section on pastie where the problem is occurring:
   [http://pastie.org/509451](http://pastie.org/509451)
 * I am sure its a matter of poor php on my part, something i need to do or not 
   do that is interfering.
 * Thanks
 *  Thread Starter [ash_learner](https://wordpress.org/support/users/ash_learner/)
 * (@ash_learner)
 * [17 years ago](https://wordpress.org/support/topic/problem-with-php-and-shortcodes/#post-1104610)
 * It looks as if its catching the greater than and less than signs at the start
   of the php strip and converting it into html special characters as shown below(
   taken from live source of the live example):
 *  `<input name="meta_web_form_id" value="<?php echo $aff_AW_Form_Id; ?>" type="
   hidden">`
 * The <?php start tag is rendering as & l t ; ?php as with the end tag (without
   the spaces)
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [17 years ago](https://wordpress.org/support/topic/problem-with-php-and-shortcodes/#post-1104649)
 * My friendly neighbourhood plugin developer has had a very quick look at the code.
   He reckons that one of your problems is that you’re creating the form in a function
   and then echoing the function – which he says won’t work with shortcodes. You
   need to **return** the value(s) from a function. He’s not sure why the php tag
   is being rendered rather than parsed. It could be an artefact of the function
   echoing.
 *  Thread Starter [ash_learner](https://wordpress.org/support/users/ash_learner/)
 * (@ash_learner)
 * [17 years ago](https://wordpress.org/support/topic/problem-with-php-and-shortcodes/#post-1104696)
 * I see, but all the examples of shortcodes I have seen have them returning html
   created within the shortcode function?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘problem with php and shortcodes’ is closed to new replies.

 * 5 replies
 * 2 participants
 * Last reply from: [ash_learner](https://wordpress.org/support/users/ash_learner/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/problem-with-php-and-shortcodes/#post-1104696)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
