problem with $unit_tag when not in the loop (form not used in post or page)
-
cf7 uses the following code to generate $unit_tag
if ( in_the_loop() ) { $unit_tag = sprintf( 'wpcf7-f%1$d-p%2$d-o%3$d', absint( $id ), get_the_ID(), $global_count ); } else { $unit_tag = sprintf( 'wpcf7-f%1$d-o%2$d', absint( $id ), $global_count ); }
conditional field for cf7 uses the following code to generate $unit tag
$unit_tag = 'wpcf7-f'.$cf7form->id().'-p'.$post->ID.'-o'.$global_count;
it works fine as long as the form is used in_the_loop().
it fails to associate javascript to form when not used in_the_loop().you should update function wpcf7cf_enqueue_scripts($cf7form)
withif ( in_the_loop() ) { $unit_tag = 'wpcf7-f'.$cf7form->id().'-p'.$post->ID.'-o'.$global_count; } else { $unit_tag = 'wpcf7-f'.$cf7form->id().'-o'.$global_count; }
basicaly, $unit_tag should not contain
"-p" . $post->ID
when used in a widget.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘problem with $unit_tag when not in the loop (form not used in post or page)’ is closed to new replies.