How to add a media with PHP

If I’m understanding correctly, each post has a filemaker, and each filemaker has only one photo? The structure is kind of unclear. Anyways, one way is top use media_sideload_image like below. However, media_sideload_image WON’T work with local files (a path on your filesystem), so you need to change your $file[‘url’] to be a valid URL … Read more

Edit image preview is not displayed

By default, wp-config.php might not have a closing tag ?> and this is acceptable and by design. The issue may arise from whitespace in some other .php file. In my case, I had whitespace after the closing tag of my functions.php file for my child theme. Once I removed that whitespace, the images are showing … Read more

Adding featured image via PHP

Use the set_post_thumbnail function. set_post_thumbnail( $post_ID, $thumbnail_id ); Require you use WordPress 3.1.0 or later. You need call this function after you have successfully created your post via wp_insert_post and have a valid $post_ID.

Image uploading stuck on “crunching”

Ok so i’m on wordpress 3.8.1 and i was having this issue and i tried EVERY FIX from every post i could find on this problem of the image upload staying stuck on “crunching” or having it say “image data does not exist” So apparently if the image dimensions (e.g. 1920×1080) are bigger than what … Read more

Using wp-uploads instead of wp-content/uploads

Well, after lots of digging (before and after posting this question), I think I figured it out. As @s_ha_dum suggests, the reason behind the odd directory placement is likely a personal preference of the person who created the Ubuntu “wordpress” package. Perhaps it makes for easier partitioning of permissions, or it makes updates more safe … Read more

Change upload_dir folder at a certain cpt but cant change back

I found! this will only change the upload dir when upload in the “rsg_download” CPT add_filter( ‘wp_handle_upload_prefilter’, ‘rsg_pre_upload’ ); function rsg_pre_upload( $file ) { add_filter( ‘upload_dir’, ‘rsg_custom_upload_dir’ ); return $file; } function rsg_custom_upload_dir( $param ) { $id = $_REQUEST[‘post_id’]; $parent = get_post( $id )->post_parent; if( “rsg_download” == get_post_type( $id ) || “rsg_download” == get_post_type( $parent … Read more

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