Metabox with multiple fields added by user and upload box

Here is how I’ve done it. No changes to the save function are needed. I’ve been trying to save data from both fields at once, thats why it didn’t worked. <input class=”upload_file” type=”text” size=”45″ id=”picture_%1$s” name=”picture_%1$s” value=”%6$s” /> <input class=”upload_button button” type=”button” value=”Upload File” /> <input class=”upload_file_id” type=”hidden” id=”picture_%1$s_id” name=”items[%1$s][picture]” value=”%7$s” /> The value stored … Read more

Randomly add a ‘ul’ list of images

Adding the following to your theme’s functions.php file will let you use a shortcode ( [wpse73055-random-images] ) with an optional num parameter (i.e. [wpse73055-random-images num=5] to display 5 random images). function wpse73055_get_random_images( $atts ) { extract( shortcode_atts( array( ‘num’ => 10 ), $atts ) ); $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ =>’image’, ‘post_status’ => … Read more

Image display from custom field

If you use update_post_meta() than also use get_post_meta() (see Codex) and not get_post_custom $order = get_post_meta( $post->ID, ‘order’, true ); $image = get_post_meta( $post->ID, ‘image’, true ); And than check in your HTML source what your image tag looks like. I bet it will look like this: <img src=”https://wordpress.stackexchange.com/questions/75550/coffee_star.jpg” /> What about the path to … Read more

Using wp_get_image_editor in a standalone script

Turns out I’m just silly. WP_Error was the undefined method, not resize. I was sending a bad image location through the resize function. How silly of me! It was working all along. I’ve included this on top $parse_uri = explode( ‘wp-content’, $_SERVER[‘SCRIPT_FILENAME’] ); require_once( $parse_uri[0] . ‘wp-load.php’ ); and this is my image resize function … Read more

Insert image in comment reply

What you’re looking for could be a wp_editor() in comment form : wp_editor( $comment->comment_content, ‘content’, array( ‘media_buttons’ => true, ‘tinymce’ => false, ‘quicktags’ => $quicktags_settings ) );

Use image url with add_image_size

The pattern you posted… www.mydomain.com/image.jpg(‘custom-thumb’); … is a bit odd. That would be pretty tricky. You’d need a PHP handler to load the image and you’d need to tell the server (Apache, Nginx, IIS, Whatever) to parse that file ending as PHP. Something like this would be simpler: www.mydomain.com/image.php?size=custom-thumb You would still need to create … Read more

Is there a shortcut to change bulk BMP images to JPG images in a site?

Assuming you add the files with the matching filenames in the appropriate wp-content/uploads/ folders you could run a few SQL queries to update the WordPress database to use the .jpg files. Assuming your wpdb prefix is wp these queries would be: UPDATE wp_posts SET post_mime_type = replace(post_mime_type, ‘image/bmp’,’image/jpeg’); UPDATE wp_posts SET guid = replace(guid, ‘.bmp’,’.jpg’); … Read more

Limit function to specific post category

You should check for category posts to modify content. Specify category ID (integer), name or slug (string), or an array of these in in_category check. function my_image_tag( $html, $id , $alt, $title ) { if ( in_category( ‘1’ ) ) { $html = “<div class=”my-class”>” . $html . “</div>”; } return $html; } add_filter( ‘get_image_tag’, … Read more