Data URI in custom fields

Hook on ‘save_post’, and after normal saving metabox routine create the data uri using php functions base64_encode and file_get_contents. With a bit of logic skip saving if not necessary (data uri already_saved). In next example I assume the post thumbnail url is setted in a metabox, and the name of the field is ‘post_thumbnail’. See … Read more

HM CMB: Role Select

There is a list of roles in the $wp_roles WordPress global object. Set $wp_roles to a global at the top of your method of function: global $wp_roles; Use a Select Field to populate the options: array( ‘id’ => $prefix . ‘role’, ‘name’ => ‘Role’, ‘type’ => ‘select’, ‘use_ajax’ => false, ‘options’ => $wp_roles->get_names(), ), Note: … Read more

Insert posting automatically based in acf field

Before inserting check if post exists: $exists = get_page_by_title( get_field(‘fornecedor’), OBJECT, ‘fornecedores’); if ( empty( $exists ) ) { wp_insert_post( array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘fornecedores’, // post_type which is created posting ‘post_title’ => get_field(‘fornecedor’), // Custom field to generate the post type ‘post_content’ => ” ) }

Plugin or shortcode for ISBN number?

I’ve had some help from a developer, and would like to share the solution: function get_google_tag( $isbn_metadata ) { return ( /* ‘<span class=”post-meta-key”>Preview: </span>’ . */ ‘<script type=”text/javascript” src=”http://books.google.com/books/previewlib.js”></script>’ . ‘<script type=”text/javascript”>’ . ‘GBS_insertPreviewButtonPopup(\’ISBN:’ . $isbn_metadata . ‘\’);’ . ‘</script>’ ); }

Custom meta boxes not saving

You are accessing the $_POST array in a wrong way. This is not possible: $_POST[‘imagefields[‘ . $i . ‘][image2]’] Correct way would be: $_POST[‘imagefields’][$i][‘image2’]; (You have the same mistake when accessing the $values array.) Also you are supposed to give the complete array to the update_post_meta() function instead of saving each value seperately: if(isset($_POST[‘imagefields’])) { … Read more