0

I have a readonly input field in my contact form created using contact form 7. I need to set the page title (<?php the_title() ?>) as the value on that readonly input.

My readonly input as follows.

[text* selected-package readonly id:selectedPackage class:form-control placeholder akismet:author "Package"]

I tried using _post_title but it only adding the value attribute to the input field, but it is not showing the value.

How can I add value attribute to this?

Thanks

Dhruvin Moradiya
  • 546
  • 2
  • 10
  • 20
WP Learner
  • 788
  • 1
  • 13
  • 34

1 Answers1

2

Check word press plugin,

Contact Form 7 Dynamic Text Extension

in which you can set,

Auto-filling a Post ID, title, or slug

set below code into your contact form 7 in admin:

[dynamictext dynamicname "CF7_get_post_var key='title'"]

You can use custom Js code by make field read only for dynamic field as well.

Ashish Patel
  • 3,551
  • 1
  • 15
  • 31
  • 1
    I can confirm that this solution is working and use **readonly** inside the shortcode like this [dynamictext dynamicname **readonly** "CF7_get_post_var key='title'"] to make the text field uneditable. Also don't change the word **dynamictext** which is inside the shortcode. You can change **dynamicname** to whatever you want. – Dushan Apr 16 '18 at 15:48