Unable to get wp_get_attachment_url to show

That’s not going to work, instead just use wp_get_attachment_image_src , it takes a size parameter. // get the $attachment_id $attach_stuff = wp_get_attachment_image_src( $attachment_id, ‘full’); var_dump($attach_stuff); You will be returned an array fo values to work with: [0] => url [1] => width [2] => height [3] => boolean: true if $url is a resized image, … Read more

How can i catch (with get_posts) attachment file (pdf, images) from a post when i have only inserted it from media library and it isn’t upload for it?

When you upload a media from a post, the post_parent attribute is setted to the post ID you are uploading from. Not so when you simple insert a post from the library: in that case if the media was already attached to a post, its post_parent is already setted, and once a media can have … Read more

Ignore image urls in wp_query search

You just need to add post_type argument like this: $wp_query = new WP_Query( array( ‘s’ => $_GET[‘s’], ‘post_type’ => array( ‘post’, /* add more post types if need be */ ), ) ); Read the codex article about WP_Query class for more information.

Let users upload image(s) to the post from front end

wp_insert_attachment returns the resulting post_ID of attachment record created in posts table, so you will need to add these IDs (multiple) in the post meta table using update_post_meta as suggested in code below: $attchmentIds = array(); if ($_FILES) { foreach ($_FILES as $file => $array) { $newupload = insert_attachment($file,$pid); $attchmentIds[] = $newupload; } }; /*The … Read more

Delete child post and attachment links to parent post

There’s no way of doing this without “listening” for the responsible database query and altering it with the query filter, thanks to this line in wp_delete_post(): // Point all attachments to this post up one level $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( ‘post_type’ => ‘attachment’ ) ); The following will override the query and set … Read more

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