Using do_shortcode() in the HEAD removes field IDs
-
The linked page has the following form definition:
<fieldset>
<label for="your-subject" class="required">Subject</label>
[select* your-subject id:your-subject "General" "Motivational Speaking" "Books" "Feedback"]
<label for="your-name" class="required">Your Name</label>
[text* your-name id:your-name akismet:author]
<label for="your-email" class="required">Your Email</label>
[email* your-email id:your-email akismet:author_email]
<label for="your-phone" class="required">Your Phone Number</label>
[tel* your-phone id:your-phone]
<label for="your-location" class="required">Your City and Country</label>
[text* your-location id:your-location]
<label for="your-message" class="required">How can we help?</label>
[textarea* your-message x5 id:your-message] [honeypot honeypot-638] [cf7-simple-turnstile]
</fieldset>
<p class="position-relative">[submit "Send"]</p>But none of the fields have the ID attribute on the front end.
I’ve tracked it down to the use of
do_shortcode()
in the scope ofwp_head
. The problem can be replicated by adding the following code:add_action( 'wp_head', function() {
global $post;
echo '<link rel="description" content="' . wp_html_excerpt( do_shortcode( $post->post_content ), 999 ) . '">';
} );When
do_shortcode()
is removed, all the fields have IDs, but not when it’s used. Everything else in the form is the same in both cases. Only the IDs are removed.In fact, running this code on any action hook down to
wp_print_scripts
has the same result, but fromloop_start
onwards, IDs come back. However, when running it oninit
, the IDs are there too.The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.