Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Wordpress

WordPress: Use Featured Images for Post Thumbnails

- 20.06.26 - ErcanOPAK

🖼️ Make Every Post Stand Out with a Thumbnail

Text-only posts are boring. Featured Images display post thumbnails. Essential for blog archives, social sharing, SEO.

📝 Enable Featured Images

// functions.php
add_theme_support('post-thumbnails');

// For specific post types
add_theme_support('post-thumbnails', array('post', 'page', 'portfolio'));

// Set custom image sizes
add_image_size('featured-large', 1200, 600, true);
add_image_size('featured-small', 300, 200, true);

// Set default image size
set_post_thumbnail_size(1200, 600, true);

🎯 Display Featured Images

// In archive template
if (has_post_thumbnail()) {
    the_post_thumbnail('featured-large');
} else {
    echo '<img src="' . get_stylesheet_directory_uri() . '/images/default.jpg" alt="Default">';
}

// Get URL of featured image
$image_url = get_the_post_thumbnail_url($post_id, 'full');

// With custom attributes
the_post_thumbnail('medium', array(
    'class' => 'img-responsive',
    'alt' => get_the_title()
));

// For Open Graph (social sharing)
if (has_post_thumbnail()) {
    $image = get_the_post_thumbnail_url(get_the_ID(), 'full');
    echo '<meta property="og:image" content="' . $image . '" />';
}

💡 Best Practices

  • Always add alt text for accessibility and SEO
  • Use descriptive filenames (not IMG_1234.jpg)
  • Optimize image size (not too large)
  • Set a default fallback image for posts without featured images
  • Use for social sharing (Open Graph)

“Posts without images looked empty. Added featured images. Archives look professional now. Social sharing improved too. Small change, big impact.”

— Blogger

Related posts:

WordPress Media Library Becomes Unusable Over Time

WordPress: Create Custom Post Types for Structured Content

WordPress Admin Slow — Heartbeat API Overload

Post Views: 1

Post navigation

Photoshop: Use Smart Filters for Editable Effects
Kubernetes: Understand Service Types — ClusterIP, NodePort, LoadBalancer

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (857)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (597)
  • Add Constraint to SQL Table to ensure email contains @ (582)
  • Average of all values in a column that are not zero in SQL (545)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (512)
  • Find numbers with more than two decimal places in SQL (460)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes
  • Ajax: Use Axios for HTTP Requests
  • JavaScript: Understand Hoisting
  • HTML: Use Web Storage for Client-Side Data
  • CSS: Use Filter Effects for Visual Magic
  • Windows 11: Unlock God Mode for All Settings

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (857)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com