How can I make thumbnails a display different size/position if the blog post was posted before a specific date?

In what way is it affecting your post thumbnails? I cleaned up your code a bit. If you can show me the output you’re getting I’ll be able to help you further. <?php global $post; $compare_date = strtotime( “2018-03-01” ); $post_date = strtotime( $post->post_date ); if ( has_post_thumbnail() ) { if ( $compare_date < $post_date … Read more

Display featured image as post thumbnail

Try this code. Then temporarily set permissions to the cache folder to 774 and the timthumb.php file to 750, you can increase or decrease the permissions as you see fit (or aslong as it stops working, then it’ll be time to loosen up the permissions). <?php // If there are images get them if ( … Read more

Source problem for children page image

Never mind about my question… here is your answer Put this function on your functions.php // Get Featured Image Path function get_featured_image_link($size){ global $post; $get_featured_image_link = get_the_post_thumbnail($post->ID, $size); preg_match(“/(?<=src=[‘|\”])[^’|\”]*?(?=[‘|\”])/i”, $get_featured_image_link, $thePath); return $get_featured_image_link_final = $thePath[0]; } Then this is the process to get the image… <?php $the_query = new WP_Query( array( ‘post_parent’ => ’20’, ‘post_type’ … Read more

Get all images from posts with maximum number and without featured image

Try this: $image_count = 0; $max_images = 10; //set this to the max number of images you want. $ids = get_posts( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1 ,’fields’ =>’ids’) ); if (count($ids) > 0){ foreach ($ids as $id){ while ($image_count < $max_images){ $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, … Read more

Featured Image Thumbnail Sizing

I’ve approached this problem in a few different ways, here’s some ideas: Just grad the medium sized thumbnail with the_post_thumbnail(‘medium’); (or any defined size that is bigger than what you want displayed), and apply a .inner .thumb img {width: 153px; height: auto;} css rule. If it’s too tall it will get cropped from your overflow:hidden; … Read more

Automatic adding thumbnail to post

This should work: $wp_upload_dir = wp_upload_dir(); $fileurl = “http://damianc.pl/th.jpg”; $filename = $upload_dir[‘path’] . DIRECTORY_SEPARATOR . basename( $fileurl ); if ( file_put_contents( $filename, file_get_contents( $fileurl ) ) ) { require_once(ABSPATH . ‘wp-admin/includes/image.php’); $wp_filetype = wp_check_filetype(basename($filename), null); $attachment = array( ‘post_mime_type’ => $wp_filetype[‘type’], ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename($filename)), ‘post_content’ => ”, ‘post_status’ => ‘inherit’ ); $attach_id = … Read more

Thumbnail images

Inside your post loop you can do; if ( has_post_thumbnail()) { echo get_the_post_thumbnail($post->ID, ‘thumbnail’); } This first checks for the existence of a featured image and if so it will display one at your default ‘thumbnail’ size as set in your settings/media options. This would also work within your loop; if ( has_post_thumbnail()) { the_post_thumbnail(‘thumbnail’); … Read more