ID of images from gallery

You can find out the IDs of which images are included in a gallery by switching to the Text editor tab and look for a piece of code like this: The comma-separated list of image IDs are enclosed in the ids attribute If you’re looking to find out IDs of existing images in order to … Read more

What is the most efficient way to retrieve a group of image URL’s from different attachment ID’s of a specific crop size?

I don’t believe there is more efficient way. Your primary object should be keeping things simple while using WP’s API which is exactly what you’re already doing. It’s true some scenarios could become pretty expensive and that is where you could take advantage of WP Object Cache or even Transients API. A good example of … Read more

How to retrieve images contained in a post

I’m guessing you’ll need to fetch the post content and parse it using something like this as a guide (pasted code from above link for future reference). // Get the all post content in a variable $posttext = $post->post_content; $posttext1 = $post->post_content; // search for the src=”” in the post content $regular_expression = ‘~src=”[^”]*”~’; $regular_expression1 … Read more

How to get boolean if file A is attached to post B

Get all attachments: $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ) ); Check attachment “parent” for each attachment. foreach($attachments as $attachment){ $parentID = $attachment->post_parent; $postID = $post->ID; if($parentID == $postID){ //your code here echo ‘This attachment belongs to the current post.’; } } But if you already have the attachment, all you … Read more

How can I let users access a specific attachment?

WordPress (or more precisely its .htaccess or alternate web server configuration file) passes through requests to existing files. The easiest way would be to start at root of your site and (using FTP/SFTP/hosting admin panel/etc): create blank01 folder create blank02 subfolder in it place file.xml into subfolder And it should just work, link will point … Read more

Custom attachment field dissapearing

I figured it out. In an effort to organize/optimize my actions and filters, there are a bunch that I only call on certain pages, using WordPress’ global $pagenow variable. I was only calling the “attachment_fields_to_edit” filter for media-upload.php, async-upload.php, and media-new.php, which apparently isn’t a valid way to do this with the new uploader. I … Read more

Move caption in on attachment page

In a theme image.php is the template that displays a single image attachment. There are many similar templates for other attachment types. The Codex has more information about attachment display templates. If you don’t have an image.php template you can quickly make one by making a copy of single.php and renaming it. Then you can … Read more

Post images not displaying as attachments

Try query post instead of $attachments = get_posts($args); or do it like <?php $args = array( ‘posts_per_page’ => 5, ‘offset’=> 1, ‘category’ => 1 ); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <li> <a href=”https://wordpress.stackexchange.com/questions/113158/<?php the_permalink(); ?>”><?php the_title(); ?></a> </li> <?php endforeach; wp_reset_postdata();?> also check this … Read more

Retreive tags from attached post for media on page

‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘post_parent’ => null, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => ‘logo’ ) ) ); $images = get_posts( $args ); if ( $images ) { foreach ( $images as $image ) { // Get the parent post ID $parent_id = $image->post_parent; // Get the … Read more

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