Tag Info

New answers tagged


These queries are in the wp_enqueue_media() function: $has_audio = $wpdb->get_var( " SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'audio%' LIMIT 1 " ); $has_video = $wpdb->get_var( " SELECT ID FROM $wpdb->posts ...


Considering WordPress Codex, and WordPress Template Hierarchy - attachments stores as post records. Your code is making a loop redirection to the same page. The most reasonable case is: Your $post->post_parent equal to 0. If you'll make a var_dump(get_permalink($post->post_parent));, youll notice that the output would be the same page url.


try get_pages with 'child_of' => get_the_ID(), 'parent' => get_the_ID(), If you need i can post full code EDIT : if ( is_singular('post') ) { $args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => null, 'parent' => $post->ID , 'child_of' => $post->ID, ...


You can also go with aq_resize function. There are second and third arguments are given for size, so you can give any size that's you want. Even you can also set these size using shortcode. Check how to pass arguments to shortcode and pass using shortcode if want to fetch dynamic size for each time function thumb_medium( $atts, $content = null ) { ...


I think your code is very close, try to use wp_get_attachment_image_src() instead: function thumb_medium( $atts, $content = null ) { // return wp_get_attachment_url( get_post_thumbnail_id( $post_id, 'medium') ); global $post; $thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium' )[0]; if ($thumb_url) { ...


I've needed to do exactly this for a plugin I'm working on and found a slightly different solution based on what Ogier did (which pointed me in the right direction thanks!) With the code provided by Ogier I found that the selected images were not appearing on top even with the extra comparitor code, so after a bit of digging around in the core and ...


To find the size of a file added through the custom fields plugin, I did this: $fileObject = get_field( 'file '); $fileSize = size_format( filesize( get_attached_file( $fileObject['id'] ) ) ); Just make sure you set the custom field's "Return Value" to "File Object".


Have you seen this ? http://stackoverflow.com/a/28429009/3967385 Actually you can't fire JavaScript with php simply like that.


You might need to require once this file: wp-admin/includes/image.php

Top 50 recent answers are included