0

I'm hoping someone might be able to help me.

I'm using the Options Framework Plugin to customise my site, but I'm having difficulty with using a shortcode in one of the custom fields.

I've created an 'editor' field, and called it in my theme like so:

<?php 
  if ( of_get_option('footer_contact_form') ) {
    echo of_get_option('footer_contact_form');
  }
?>

But it outputs the shortcode (gravity forms) as raw text, like so: https://dl.dropboxusercontent.com/u/4676147/shortcode-output.png

Is it possible to achieve what I'm trying, or will I have to hard code the form into the theme?

Many thanks in advance!

0

You should check out the WordPress function do_shortcode().

You can use it to generate the shortcodes, in a string variable, like this :

<?php echo do_shortcode( $content ) ?>

So in your case, please try:

<?php 
  if ( of_get_option('footer_contact_form') ) {
      echo do_shortcode( of_get_option('footer_contact_form') ); 
 }
?>

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.