WordPress PHP custom function is causing 500 Internal Server Error Connection Timeout

This function is completely unnecessary, and can be replaced with the official WP function called media_sideload_image: media_sideload_image( string $file, int $post_id, string $desc = null, string $return = ‘html’ ) for example: $new_image_id = media_sideload_image( “https://example.com/image.png”, $post_id, “Toms great picture”, ‘ID’ ); https://developer.wordpress.org/reference/functions/media_sideload_image/ Don’t forget to check the result, if this fails it will return … Read more

Image title replace with current date

You can achieve this by using following code: /* Automatically set the image Title, Alt-Text, Caption & Description upon upload ————————————————————————————–*/ add_action( ‘add_attachment’, ‘my_set_image_meta_upon_image_upload’ ); function my_set_image_meta_upon_image_upload( $post_ID ) { // Check if uploaded file is an image, else do nothing if ( wp_attachment_is_image( $post_ID ) ) { $custom_title = date(“Y-m-d”); //settings current date as … Read more