Get attachment file link

Well, there is a WP function for that. wp_get_attachment_url It takes attachment id as argument, so you can use it like in following example: echo wp_get_attachment_url( 12 ); This will echo url to attachment which id is 12. You can find more info and examples on Codex page: https://codex.wordpress.org/Function_Reference/wp_get_attachment_url

search through post-type attachments titles

You should try applying the s(search) as parameter for your custom query. See this example here: $query = new WP_Query( ‘s=keyword’ ); and you can then apply normal loop to iterate through your results. This also performs string match same as like operator %keyword% you mentioned in comment for @Ravs’ answer. Refer documentation here.

How to allow specific extensions and file size to wp_mail attachment?

Add the following condition before the file upload functionality – $allowedExts = array(“pdf”, “jpg”, “png”); $temp = explode(“.”, $_FILES[“attachment”][“name”]); $extension = end($temp); if ((($_FILES[“file”][“type”] == “image/pdf”) || ($_FILES[“file”][“type”] == “image/jpg”) || ($_FILES[“file”][“type”] == “image/png”)) && ($_FILES[“file”][“size”] < 1000000) && in_array($extension, $allowedExts)) { //your file upload code and other stuffs } else { echo “Invalid file”; … Read more