How to set featured image to custom post from outside programmatically

Can’t this simply be done with media_sideload_image() ? Seems pretty simple. Only catch is if you aren’t on admin area, you must include some libraries from within WordPress includes: // only need these if performing outside of admin environment require_once(ABSPATH . ‘wp-admin/includes/media.php’); require_once(ABSPATH . ‘wp-admin/includes/file.php’); require_once(ABSPATH . ‘wp-admin/includes/image.php’); // example image $image=”http://example.com/logo.png”; // magic sideload … Read more

Upload Multiple Files With media_handle_upload

here if you use custom template past this in the begining <?php if( ‘POST’ == $_SERVER[‘REQUEST_METHOD’] ) { if ( $_FILES ) { $files = $_FILES[“my_file_upload”]; foreach ($files[‘name’] as $key => $value) { if ($files[‘name’][$key]) { $file = array( ‘name’ => $files[‘name’][$key], ‘type’ => $files[‘type’][$key], ‘tmp_name’ => $files[‘tmp_name’][$key], ‘error’ => $files[‘error’][$key], ‘size’ => $files[‘size’][$key] ); … Read more

Add a Meta Box for uploading a SECOND Featured Image?

The functionality you want may be built from scratch but definitely a custom fields plugin will make your life much easier. I use Advanced Custom Fields, and it gives amazing results and the possibilities are endless. I haven’t used this one, but it seems pretty good too.

How to Require a Minimum Image Dimension for Uploading?

Add this code to your theme’s functions.php file, and it will limit minimum image dimentions add_filter(‘wp_handle_upload_prefilter’,’tc_handle_upload_prefilter’); function tc_handle_upload_prefilter($file) { $img=getimagesize($file[‘tmp_name’]); $minimum = array(‘width’ => ‘640’, ‘height’ => ‘480’); $width= $img[0]; $height =$img[1]; if ($width < $minimum[‘width’] ) return array(“error”=>”Image dimensions are too small. Minimum width is {$minimum[‘width’]}px. Uploaded image width is $width px”); elseif ($height … Read more

Media files exist in upload folder but not showing up

Just by uploading files into the wp-content/uploads won’t show up in the Media Library , those media ID’s needs to be there in the database to show up in the Media Library. If you already have files in the uploads folder and want to add them into the database, you can use this plugin to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)