How would I retrieve attachments from all subpages of a specific Page ID? Example: SPECIFIC PAGE Child (with attachments) Child (with attachments) Child (with attachments) I'm currently using this code to retrieve all attachments site-wide, however I would like to limit this to only pull images from all children of a specific Page. $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null ); $attachments = get_posts( $args ); if ( $attachments ) { foreach …
I am using an attachment.php file to show large versions of images that have been clicked on elsewhere. I'd like to pull the image alt text as a caption under the image with javascript, but the alt text isn't included when when wp_get_attachment_image_src() is used. I don't think WP has a function to retrieve it, so I need my own. To write that function I need to know...Where is the alt text for an image stored? My attachment page uses …
On my site I hava two forms witch send email. The one whit no attachment needed is sent correnctly, but the other ony witch has an attachment does not get sent. I am using SMTP config whit Postman SMTP plugin. move_uploaded_file($_FILES["cv"]["tmp_name"],WP_CONTENT_DIR .'/uploads/CV/'.basename($_FILES['cv']['name'])); move_uploaded_file($_FILES["lm"]["tmp_name"],WP_CONTENT_DIR .'/uploads/lm/'.basename($_FILES['lm']['name'])); $attachments = array( WP_CONTENT_DIR ."/uploads/CV/".$_FILES["cv"]["name"], WP_CONTENT_DIR ."/uploads/lm/".$_FILES["lm"]["name"] ); this is the code I use for storeing and reaching the attachments and simpli useing the wp_mail function to send it like this: $sent=wp_mail($s, $subject, $message, $headers,$attachments); On …
I have developed a custom wordpress panel with a custom front-end recently. In single post pages there is a slider. I display the result of get_attached_media( 'image' ) function as the images of slider. I told editor that upload only the images you would like to see in slider to post from edit post page, upload other images from the media link on the side menu. The problem is that, if the user uploads an image from media screen, then …
I want start saying that I'm learning and I'm trying to understand the use of $_FILES and $file_handler which are making me crazy into this function to upload attachments from a frontend form. What I've discovered into mine yesterday question was that using $_FILES into the same function makes it overwritten so some nice dude suggested to change this variable in something different like $whatever. Both files could be managed and uploaded then but of course this is not happening …
I have a problem with images. I can see my uploaded images, as previously, through the media library. I can access each image by clicking on "edit". But if I then click on "View Attachment Page", I am taken to the "404! We couldn't find the page!" message. This applies to all images in the library. At the same, images in some posts (but not all) are behaving differently from before. It used to be possible for readers to click …
Basically, I'm trying to call attachment info to display withing a loop, for use in an image gallery. I know I need to use wp_prepare_attachment_for_js($attachment_id) but I can't seem to get anything to show. Here's the HTML: <?php $the_query = new WP_Query(array( 'post_type' => 'attachment', 'post_status' => 'inherit' )); while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php attachment_meta = wp_get_attachment($id); echo '<figure class="gallery-photo" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject" data-groups='["all", "'.$attachment_meta['category_name'].'"]'><a class="photo-link" href="'.wp_get_attachment_image ().'">" itemprop="contentUrl" data-size="'.$attachment_meta[width].'"x"'.$attachment_meta[height].';?>"> <img src="'.wp_get_attachment_url ('fullsize').'" itemprop="thumbnail" /> <figcaption itemprop="caption …
In Google WebMaster Tools the crawling errors page is showing 177 missing urls. Most of them are showing as ?attachment_id=xxx I have looked in the database for these id's in the wp_posts table but they do not exist. I have marked these errors in Google Webmaster Tools as fixed, but they keep coming back. Where else should I look at ? There must be a reference somewhere to these urls, but I can't find it.
I want to display images under for each comment but images store in database as serialized a:3:{i:0;i:775;i:1;i:776;i:2;i:777;} I wrote this code print_r (get_comment_meta( $comment->comment_ID , 'reviews-images', true )); but it outputs this * Array ( [0] => 778 [1] => 779 [2] => 780 [3] => 781 [4] => 782 ) 10 then I tried this echo get_comment_meta( $comment->comment_ID, 'reviews-images', true ); not worked . Please help how can I get image urls instead of this output
In the past, when selecting a picture in the media library, you could see the "attachment display settings". I installed wordpress 5.3.2, I uploaded an image to the media library. I don't see attachment display settings anymore. This is also nowhere to be seen in the image block of wordpress. Was it removed, or is it my installation of wordpress?
I have a form that visitors use to upload files and fill out information about them and a function that adds those files to the media library and set various fields (including some custom taxonomies) on the media library items based on fields that the visitor filled out in the form. The problem is, I have an email address field. When a visitor fills out the email address field with "[email protected]", what is displayed on the Attachment details screen (as …
I've been searching high and low trying to figure out how to create download links for audio files uploaded to a post. I know how to display the audio url directly into the theme template, but when it's clicked, it just starts to stream the audio right in the browser. I need a way to prompt the file to download once clicked. Looking for more of a snippet for the functions.php file than a plugin.
I'd like to retrieve a list of all attachment URLs for all posts of a website. This would bring something like http://example.com/mypost/attachment-1/ http://example.com/mypost/attachment-2/ http://example.com/anotherpost/attachment-deff/ http://example.com/post3/attachment-deff4/ Would it imply to use: wp_get_attachment_url
I'm having an issue where the attachment is being deleted despite me returning false function action_maybe_delete( $id ) { echo "Let's not delete Attachment id: " . $id ; // prevent the attachment from actually being deleted if( 1 == 1 ) { // made up condition return false; } }; // add the action add_action( 'delete_attachment', 'action_maybe_delete', 10, 1 ); When i run code similar to the above from the media library, it calls admin_ajax.php it echos the mesage …
I have not been able to find a reliable solution for how to lookup the id for attachments in the media library from a filename as Wordpress does not appear to provide such a function. Most solutions rely on searching the GUID field in various tables, however there are issues with attachments uploaded with greater than 2560px resolution. Wordpress appends '-scaled' to the filename returned by functions like get_attached_file(), but this is not reflected in the guid database column. I'd …
How do I delete or remove the word Delete Permanently in uploading files? I wanted to remove this permanently so that the users won't keep deleting files which are not supposed to delete. I use this code: .button-link.delete-attachment{display:none} But the problem of this, if the user uses the inspect element, they can just change it to display:block to show the delete button. Using CSS is not an option. Is there a function code here to remove this? Or where can …
I'm using the function wp_insert_attachment() to run on a form submission from GravityForms, take a file uploaded in the form, and add it to the WordPress Media Library. Code in functions.php below, also in Github: function form_to_media_library($entry){ // from https://developer.wordpress.org/reference/functions/wp_insert_attachment/#div-comment-948 // set filename $upload_path = GFFormsModel::get_upload_path( $entry[ 'form_id' ] ); $upload_url = GFFormsModel::get_upload_url( $entry[ 'form_id' ] ); $filename_verbose = str_replace( $upload_url, $upload_path, $entry[ '1' ] ); $filename = trim($filename_verbose, ' "[]\ '); // check the type of file. We'll use …