Function to get thumbnail img source

wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); all together: <div class=”entry-thumbnail”> <a rel=”lightbox” href=”https://wordpress.stackexchange.com/questions/107218/<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>”><?php echo get_the_post_thumbnail( $post->ID ); ?></a> </div>

Retrieve post thumbnails

<?php /* Template Name: Ron’s WordPress Answers Template */ include_once(‘header.php’); $args = array( ‘posts_per_page’ => 5, ‘offset’ => 0, ‘category’ => ”,//you have to use the category id # here not the name of the cat ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘suppress_filters’ => true ); $posts = get_posts( … Read more

Post Images Size Change in WordPress

First of all set the image size in Settings > Media or seta customized image size using add_image_size function. New images you will upload will be right size, but for images already uploaded you have to recreate the image sizes, for the pourpose you can use the plugin Regenerate Thumbnails Hope it helps.

wp_get_attachment_image_src() does not return what I want

The following is entirely based on experiment over the last 15 minutes or so, so I wouldn’t call it canonical but … wp_get_attachment_image_src() uses the image_downsize() function, which will attempt to find and return the image closest in size to the supplied size values. If you experiment with know image sizes (look at the actual … Read more

Making a thumbnail if there exist a link with. jpg or .png extension in WordPress

1) Check out: http://codex.wordpress.org/Function_Reference/media_sideload_image 2) I found that WP function to be somewhat limited to I wrote my own wrapper class/method. If you want to do the same you’re going to need PHP’s copy() function http://us2.php.net/manual/en/function.copy.php as well as WP’s wp_insert_attachment() http://codex.wordpress.org/Function_Reference/wp_insert_attachment Unfortunately, I haven’t pushed my code to GitHub just yet, so for now … Read more