Regarding to the performances, should I check if a post has a thumbnail before or after checking if is the front page (or single page, etc.)?

Neither, they are just as fast as each other, both are using information that has already been fetched in advance. This is micro-optimising. Functions such as is_front_page or is_singular etc etc are just looking up variables already set in the main query object. Likewise functions such as has_post_thumbnail etc are looking up data that has … Read more

Get Post Thumbnail Outside of Loop

Off top of my head here’s two possible solution concepts. 1) Just run the custom loop (I meant to type, query) again and this time use it with only the_post_thumbnail. <?php if ($myposts->have_posts() ) : ?> <div class=”image-wrapper e-in”> <?php while ($myposts ->have_posts() ) : $myposts ->the_post(); ?> <div class=”image “> <!–Post Iamge Will Show … Read more

php code for image fetching

How to fetch the featured image in wordpress post[?] echo get_the_post_thumbnail( $post_id ); Or, inside a proper Loop, the_post_thumbnail(); But I have a feeling that there is information missing from the question. You aren’t using any Core functions and there is no explanation why, or reasons why not. For example, WP_Query would be far easier … Read more

wordpress featured image

The most simple form of the featured images (post thumbnails) looks like this: You need to have this piece of code in your functions.php file: add_theme_support( ‘post-thumbnails’ ); Then in the index.php, or any other template file you want to show the post thumb or featured images, you would add this: <?php the_post_thumbnail( ‘thumbnail’ ); … Read more