wordpress.com Alice主题Custom Post types特色图片丢失问题求助
Hey there, let's work through this featured image issue you're seeing with the Team custom post type in the Alice theme on WordPress.com. Migrated sites can sometimes have quirky media handling glitches, so here are the steps I'd recommend trying—starting with the simplest checks first:
Double-check your featured image setup
Don't overlook the basics first:- Confirm the image you're uploading is a supported format (JPG, PNG, WebP) and isn't corrupted. Try uploading a different test image to rule out file-specific issues.
- When editing a Team entry, make sure you've actually selected and saved the Featured Image (it's easy to click "Set Featured Image" and forget to hit "Update" on the post itself). Refresh the entry after saving to ensure the image stays assigned.
Re-enable featured image support for the Team post type
Even though Alice is built to support these custom post types, migrations can sometimes break the theme's built-in support declarations. To fix this, add a small code snippet:- Go to your WordPress.com site's Tools > Code Snippets (or access the theme editor if you have the Business plan)
- Create a new snippet with this code:
add_action('init', 'enable_team_featured_images'); function enable_team_featured_images() { add_post_type_support('team', 'thumbnail'); } - Activate the snippet, then go back to your Team entries and re-set the featured images.
Inspect the theme's template code for image calls
Thesrc(unknown)error usually means the theme is trying to pull an image from a non-existent field or using an incorrect function. If you have access to the theme's template files:- Look for the Team module template (likely in
template-parts/or ateam/subfolder, e.g.,team-item.php) - Check how the featured image is being called. It should use WordPress's native functions like
get_the_post_thumbnail_url()orthe_post_thumbnail(). For example:// Correct background image usage echo '<div class="team-image" style="background-image: url(' . get_the_post_thumbnail_url(get_the_ID(), 'medium') . ')"></div>'; - If you see code referencing custom fields (like
get_post_meta()) or hardcoded paths instead of these native functions, that's probably the issue. Update the code to use the proper featured image functions.
- Look for the Team module template (likely in
Clear WordPress.com's cache
WordPress.com automatically caches your site to boost performance, and sometimes cached old content can stick around after you update images. Head to Settings > Performance in your dashboard, find the cache section, and click "Clear Cache". Then refresh your front-end page to see if the images load.Re-upload images if they're migrated from an old site
If the site was migrated, it's possible the featured images are still pointing to the old server's file paths (which are no longer accessible). In this case:- Delete the existing "missing" images from your Team entries
- Re-upload the images directly to your WordPress.com media library
- Re-assign them as featured images for each Team entry
内容的提问来源于stack exchange,提问作者jlehenbauer

