Last active
October 2, 2018 14:24
-
-
Save jaredatch/a083be5a5afdb2d2e74ab63076a6325b to your computer and use it in GitHub Desktop.
WPForms move field descriptions to top of field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Move a single field descriptions to the top of the field, under the label. | |
* | |
*/ | |
function wpf_top_field_descriptions() { | |
?> | |
<script type="text/javascript"> | |
jQuery(function($){ | |
var $desc = $('#wpforms-1287-field_1-container .wpforms-field-description'), | |
$field = $desc.closest('.wpforms-field'); | |
$desc.css('margin', '0 0 8px 0'); | |
$field.find('.wpforms-field-label').after($desc); | |
}); | |
</script> | |
<?php | |
} | |
add_action( 'wpforms_wp_footer', 'wpf_top_field_descriptions' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Move all field descriptions to the top of the field, under the label. | |
* | |
*/ | |
function wpf_top_field_descriptions() { | |
?> | |
<script type="text/javascript"> | |
jQuery(function($){ | |
$('.wpforms-field-description').each(function(index, el) { | |
var $desc = $(this), | |
$field = $desc.closest('.wpforms-field'); | |
$desc.css('margin', '0 0 8px 0'); | |
$field.find('.wpforms-field-label').after($desc); | |
}); | |
}); | |
</script> | |
<?php | |
} | |
add_action( 'wpforms_wp_footer', 'wpf_top_field_descriptions' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are no filters available to move the description to the top. In this particular snippet, I'm also changing the description font-size: https://gist.github.com/3f0dc8a229df3e94ac3c9fe22f1eb32b