Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

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

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Wordpress

WordPress: Fix Featured Images Missing on the AMP Version of a Post

- 27.11.26 - ErcanOPAK

📝 WordPress: Fix Featured Images Missing on the AMP Version of a Post

Most AMP plugins generate their markup from a post’s content and template independently of the normal theme, which means a featured image set through a theme’s own custom meta box — rather than the native _thumbnail_id post meta key that set_post_thumbnail() writes to — is invisible to the AMP renderer even though it displays perfectly on the regular, non-AMP page.

🔎 The Problem

// Regular theme template - works fine
if ( has_post_thumbnail() ) {
    the_post_thumbnail( 'large' );
}

// AMP plugin's own template hook reads the same function,
// but the image was actually set via a theme option field
// (update_post_meta($id, 'theme_custom_hero_image', $url))
// instead of set_post_thumbnail() -> _thumbnail_id was never set
// has_post_thumbnail() returns false under the AMP template too

✅ Fix: Make the Native Thumbnail the Source of Truth

  • Set the image through the standard Featured Image panel (which calls set_post_thumbnail()) instead of a theme’s custom hero-image field, so every consumer of _thumbnail_id — AMP plugin included — sees the same value.
  • If the custom field must stay for legacy reasons, hook into save_post to mirror its value into set_post_thumbnail() as well, so both code paths stay in sync going forward.
  • Run a one-time script over existing posts that backfills _thumbnail_id from the custom field, so AMP pages for already-published posts pick up the same image without re-editing each one by hand.

🚨 Why This Is Dangerous

  • A post that looks complete in the regular editor preview can render with a blank, broken-looking header on every AMP page Google serves from search results, which is exactly the version of the page most mobile visitors actually land on.

A plugin that reads the standard featured-image field will never see an image that was only ever saved somewhere else.

— WordPress Admin

Related posts:

WordPress: Use Autoptimize to Minify CSS/JS Without Coding

WordPress: Use Autoptimize to Minify CSS/JS Without Coding

WordPress: Master Database Health Check for Peak Performance

WordPress: Master Database Health Check for Peak Performance

How to solve WordPress Briefly unavailable for scheduled maintenance. problem

How to solve WordPress "Briefly unavailable for scheduled maintenance." problem

Views: 6
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

C#: Fix an IAsyncEnumerable Loop Leaking a Connection on Break
HTML5: Fix a Details Toggle Not Reaching an Assistive Reader

Leave a Reply Cancel reply

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

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 996 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 995 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 866 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 629 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

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

Social

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