Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Last active October 2, 2018 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatch/a083be5a5afdb2d2e74ab63076a6325b to your computer and use it in GitHub Desktop.
Save jaredatch/a083be5a5afdb2d2e74ab63076a6325b to your computer and use it in GitHub Desktop.
WPForms move field descriptions to top of field
<?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' );
<?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' );
@jtsternberg
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment