Attach pdf from dynamic url

You can try to do it in two ways. The first one, much more simple, is to save a temporary PDF file somewhere, for example in a uploads directory, use it as attachment and delete if after the call to wp_mail() function is made: function my_custom_save_post( $post_id, $post, $update ) { if( ! $update ) … Read more

Attachment pages stealing page slugs

I’ve found a workaround if someone has the same problem: In the database, you can search for the attachment page that’s causing problem, you’ll find it in wp_posts by searching for its post_name (which is the slug you want). Then just rename that post_name (in about-img for example). It isn’t a fix but it will … Read more

how to get random media id from media gallery

You can use get_posts() function to get random post, without additional php manipulation. Just change default orderby attribute to “rand” and set number of posts attribute equals to “1”. $image = get_posts( array( ‘orderby’ => ‘rand’, //random order ‘numberposts’ => 1, // numberposts, not posts_per_page ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘post_status’ => ‘inherit’ ) … Read more

Returning data instead of echoing/printing

The problem with your code, as you mentioned, is that you are outputting the images via your print_r function, and you need to instead build a string to return, which is displayed in place of the shortcode. Give this a try: function get_media () { $attachments = get_posts([ ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ … Read more

Getting Different Size Of Attachment Images

Since you have defined the featured image for each post with using <?php the_post_thumbnail( ‘custombig’ ); // or another custom size name ?> should be enough, for info you can read: http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/ Or here there is good info too: How wordpress handle upload images and how to use them in the code

filter get_children to return all mime types EXCEPT ‘x’

Looks like this is two questions: how to get all the children that are audio, and how to get all the children that aren’t audio. 1) The post_mime_type parameter of get_children can actually take a wildcard, so you could use: $children = get_children(array( ‘post_parent’ => $post->ID, ‘post_status’ => ‘inherit’, ‘post_type’ => ‘attachment’, ‘post_mime_type => ‘audio/%’ … Read more

wp get attachment image always gives me thumbnail

The real workhorses behind wp_get_attachment_image_src are image_downsize & image_get_intermediate_size. Between the two, they’ll attempt to find the largest image available that fits within the constraints of the required size. The return value of wp_get_attachment_image_src will be: Array( [0] => ‘source of image that best fits’, [1] => ‘width of source image’ [2] => ‘height of … Read more

Create page from post attachments

You can. I think, you should do that with page-template. For that, create a page template. Easiest way is: 1) Inside your theme folder, make a duplicate of page.php and name it i.e. my-page.php 2) open that file and in the top, after <?php place this: /** * Template Name: my templt for attchmnts */ … Read more

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