Skip to content

Instantly share code, notes, and snippets.

View misfist's full-sized avatar

P. E. A. Lutz misfist

  • NYC
View GitHub Profile
@misfist
misfist / media-utilties.php
Last active January 24, 2018 20:31 — forked from claudiosanches/functions.php
WordPress - Get a first image attachment in post
<?php
function prefix_get_first_attachment( $post ) {
$attachment = get_children(
array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'DESC',
'numberposts' => 1,
)
<?php
//Change error message of AJAX submitted form.
add_filter( 'caldera_forms_render_notices', function( $notices ){
//Will NOT be set (during AJAX return) if there is no error
if( isset( $notices[ 'error' ], $notices[ 'error' ][ 'note' ] ) ){
$notices[ 'error' ][ 'note' ] = 'Form could not be submitted, please correct erorrs or give us a call.';
}
return $notices;
});