I have a shordcode for Contact Form 7 form. I want use Advanced Custom Fields for ID value. How Can I do that?

the ACF with ID value:



<?php echo do_shortcode( '[contact-form-7 id="29"]' ); ?>

Any solution? :)

2 Answers 2


Simple as this:

<?php echo do_shortcode( '[contact-form-7 id="'.get_field('form').'"]' ); ?>

You have to notice, you should use get_field() to return the value. the_field() will echo it.

  • 1
    Great! Thank you so much! I've done that before but I miss the ' '. Thanks a lot!
    – D_P
    Jul 29, 2017 at 19:41
  • You're most welcome :) enjoy.
    – Johansson
    Jul 29, 2017 at 19:42

Another way:

Copy your shortcode in your WordPress text field:

[contact-form-7 id="29"]


<?php echo do_shortcode(get_field('form')); ?>

Very small difference, a little bit easier.

Your Answer

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

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