why when I try to insert an image attachment along with a post does wp_get_attachment_url give me a very wrong file path?

It turns out I was barking up the wrong (or at least a slightly different) tree by using wp_insert_attachment. media_sideload_image managed to pull attachments from other blogs on the same multisite install, copy them to the aggregating blog’s uploads directory, and generate thumbnails, while wp_insert_attachment was doing what it was supposed to, which just happened … Read more

Delete all thumbnails for a post

Using wp_delete_attachment( $attachmentid, true ) is only thing you need. Passing true as second argument, ($force_delete see codex ) it: remove the thumbnail association with any post delete any taxonomy associated to attachment and of course remove all the files, also the autogenerated ones So you do not need to also use delete_post_thumbnail().

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.

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