Thumbnails not showing in blog

The loop term in WP refers to concept of iterating over post objects and (typically) filling global variables with data of current one. It can be identified by one of: the_post() function calls (main loop) $some_variable->the_post() method calls (secondary loops using WP_Query object) setup_postdata( $post ) (more raw version, working with array of post objects) … Read more

Hide feature image when is not populated

I guess the <div class=”single-post-thumb” > is the one with the border etc. Change your code to this: if ( has_post_thumbnail( ) ) { echo ‘<div class=”single-post-thumb” >’; tie_thumb( ”, $width, $height ); if ( get_post( get_post_thumbnail_id( ) )->post_excerpt ) { echo ‘<div class=”post_thumbnail-caption”>’ . get_post( get_post_thumbnail_id( ) )->post_excerpt . ‘</div>’; This will cause the … Read more

Displaying All Parent Pages as Featured Images

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

Always generate thumbnail after sideloading image

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

How to remove featured images from posts

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 🙂

Link from Thumbnail to Post not working

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

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