wp_mail attachment not working in wordpress

You don’t need to know the file names before, you’ll have access to them. I saw you using $subject = $_POST[‘subject’]; – this means the subject will be the value of the input with the name of “subject”. In your case, this one : <input id=”subject” class=”form-control” name=”subject” type=”text” /></div> We can use the same … Read more

Media library upload hook

I think what you need is media_upload_{$type} hook. Here’s the documentation for it: https://developer.wordpress.org/reference/hooks/media_upload_type/ There’s also an easier way to achieve a similar result, by using the filter wp_handle_upload which is really straightforward. Here’s the doc about it: https://developer.wordpress.org/reference/hooks/wp_handle_upload/ If you could provide more details about the result you want to achieve, I’ll try my … Read more

Attachement Meta DATA

That is the attachment’s data in serialized format. There’s an explanation of the data in the wp_get_attachment_metadata codex entry. If you have some custom function doing image uploading, you can use wp_generate_attachment_metadata to generate that data.

Count images in post then add class if just one

Using @pascalvgemert’s suggestion as a starting point, I’m using the following script: jQuery(document).ready(function() { var imgCount = jQuery(“.single-post #content-left p a”).children(“img”).length; if (imgCount == 1) { jQuery(“img”).addClass(“lone-image”); } }); Works like a charm.

Bulk delete media by year

We tried with couple of plugins , but there isn’t any with option to bulk delete images by month or year. If you have access to wp-cli you can try to delete attachments by year and month with: wp post delete $(wp post list –post_type=”attachment” -—year=2016 -—monthnum=12 –format=ids) or just by year with: wp post … Read more

Open attachments in new tab/window

Presuming you don’t have a blank install have you tried disabling all your active plugins to see if it might be a conflict? If you can set the links to open in a new window when no plugins are active then activate one plugin at a time to figure out the culprit. Also check if … Read more

Custom Fields, Media uploader, Attachments

There are a few different ways to get your values. One way is in the loop and another way is outside the loop. Here is a short code snippet that can be used to get them outside the loop ( untested ) <?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, ‘customField’, true); ?> You will … Read more