You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在WordPress 4.9.1的Twenty Ten主题中移除特定页面头部图片

Remove Header Image on Specific Pages in Twenty Ten (WordPress 4.9.1)

Hey there! I’ve got you covered on removing the header image only from specific pages in the Twenty Ten theme for WordPress 4.9.1. The issue with generic CSS you found is likely because you weren’t targeting the pages specifically enough—let’s fix that with two reliable methods:

Method 1: Custom CSS (Easiest for Most Users)

First, you need to get the unique ID of the pages where you want to remove the header image:

  • Go to Pages > All Pages in your WordPress dashboard, hover over the page title, and look at the bottom of your browser for a URL like post=123—the number here is your page ID.
  • Alternatively, open the page in your browser, right-click anywhere and select Inspect. Look for the <body> tag; it will have a class like page-id-123 (the number is your page ID).

Once you have the page ID(s), add this custom CSS to your theme:

  1. Go to Appearance > Customize > Additional CSS (this is the safest place to add custom CSS without losing it on theme updates).
  2. Paste the following code, replacing 123 with your actual page ID. Add more lines for additional pages:
/* Remove header image from page ID 123 */
body.page-id-123 #branding img.header-image {
    display: none;
}

/* Add another page if needed */
body.page-id-456 #branding img.header-image {
    display: none;
}
  • The #branding is the container for the header in Twenty Ten, and .header-image targets the actual header image specifically. This should override the theme’s default styles. If it still doesn’t work, you can add !important (though use this sparingly):
body.page-id-123 #branding img.header-image {
    display: none !important;
}

Method 2: PHP Snippet (More Control, No CSS Hiding)

If you want to completely prevent the header image from loading (instead of just hiding it), use this PHP snippet in your child theme’s functions.php file (never edit the parent theme directly!):

function remove_specific_page_header_image() {
    // Replace 123 and 456 with your target page IDs
    $target_pages = array( 123, 456 );
    if ( is_page( $target_pages ) ) {
        // Remove the header image action from Twenty Ten
        remove_action( 'twentyten_header', 'twentyten_header_image', 10 );
    }
}
add_action( 'wp', 'remove_specific_page_header_image' );
  • This hooks into WordPress to stop the theme from outputting the header image entirely on the specified pages, which is more efficient than hiding it with CSS.

Troubleshooting Tips

  • If CSS isn’t working, clear your browser cache and any WordPress caching plugins you might be using—sometimes old styles get stuck.
  • Make sure you’re using the correct page ID; double-check the body class or edit URL to confirm.

内容的提问来源于stack exchange,提问作者fdarn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:32:31