Featured Image metabox (postimagediv) doesn’t appears when it should
Featured Image metabox (postimagediv) doesn’t appears when it should
Featured Image metabox (postimagediv) doesn’t appears when it should
To get all the “root” pages of a site: $args = array( ‘post_type’ => ‘page’, ‘child_of’ => 0, ); $pages = get_pages( $args ); foreach( $pages as $page ) { if( has_post_thumbnail( $page->ID ) { $imgdata = wp_get_attachment_image_src( get_post_thumbnail_id(), ‘large’ ); $imgwidth = $imgdata[1]; // thumbnail’s width $imgheight = $imgdata[2]; // thumbnail’s height } } … Read more
You’ll have to use wp_generate_attachment_metadata and wp_update_attachment_metadata to do this. // sideload it into wordpress (generates various sizes) $thumbid = media_handle_sideload( $file_array, $post->ID ); if ( is_wp_error($thumbid) ) { // deal with error here } // If this function is undefined in the environment where it is to be used, // such as within a … Read more
Use Developer tools in Google Chrome and see what section is responsible for displaying the featured image on post page. Open page.php or single.php (relevant file responsible for generating single page) and delete that code. Keep a backup of the file before making any changes 🙂
My issue was down to some images being smaller than the required width and/or height. Something so simple but I hope it helps others in the future.
You probably have more than one query in your page, let’s make sure we are working with this query: <?php $carouselPosts = new WP_Query(); $carouselPosts->query(‘showposts=3’); // checking if there are posts to show if($carouselPosts->posts){ foreach ($carouselPosts->posts as $carouselPost) { echo ‘<a href=”‘. get_permalink($carouselPost->ID). ‘”>’; echo ‘<div class=”recentpostthumbnail”>’; echo get_the_post_thumbnail($carouselPost->ID,array(70,70)); echo ‘</div>’; echo ‘</a>’; $excerpt = … Read more
Pointing Existing featured images to s3 bucket
This widget class uses the functionwp_widget_rss_output(), and there is no filter to change its output. So the answer is: no. But you can create your own RSS widget and replace the default widget with an improved version.
You need to create a function for that. Use this code below in your functions.php file and it will add a featured image automatically: /* Generate Featured Image Automatically */ function autoset_featured() { global $post; $already_has_thumb = has_post_thumbnail($post->ID); if (!$already_has_thumb) { $attached_image = get_children( “post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1” ); if ($attached_image) { foreach ($attached_image as $attachment_id => $attachment) … Read more
You can do this by using conditionals for mobile ie: wp_is_mobile() Define both the sizes like add_image_size( ‘featured-cat’, 248, 110, true ); //featured-cat add_image_size( ‘featured-cat-mobile’, 200, 80, true ); //featured-cat mobile and edit the code like the below:– <?php echo ‘<div class=”featured-thumbnail”>’; if( wp_is_mobile() ) the_post_thumbnail(‘featured-cat-mobile’,array(‘title’ => ”)); else the_post_thumbnail(‘featured-cat’,array(‘title’ => ”)); echo ‘</div>’; ?>