如何移除WordPress公开页面中的‘text’内容及板块?(附图片)
Hey there! Let's tackle these two WordPress tweaks you're asking about—removing that "text" content and the entire "text" section from your public pages. I'll break down straightforward, actionable methods for each below:
Depending on how that text is added to your site, you have a couple of solid options:
Quick visual hide with CSS (no coding experience needed)
Head to your WordPress dashboard → Appearance → Customize → Additional CSS, then paste in this snippet (you'll need to tweak the selector to match your site's code):/* Replace .target-text-content with the actual selector for your text */ .target-text-content { display: none !important; }Pro tip: To find the right selector, right-click the "text" content on your public page → select "Inspect" (Chrome/Firefox). Look for a class or ID attached to the HTML element wrapping the text, then swap that in for
.target-text-content.Permanent removal with PHP (stops the content from loading entirely)
If the text is added via a theme or plugin hook, you can remove it entirely by editing your child theme'sfunctions.phpfile (always use a child theme to avoid losing changes when your parent theme updates):// Replace 'hook_name' and 'text_output_function' with the actual values for your site remove_action('hook_name', 'text_output_function');If you're not sure which hook to target, temporarily add this snippet to
functions.phpto list all active hooks (delete it after you find what you need):add_action('wp_footer', function() { global $wp_filter; print_r($wp_filter); });
Removing the entire section works similarly, but we'll target the container holding the "text" content instead:
Quick CSS hide for the whole section
Use the same Custom CSS panel as above, but target the section's container:/* Replace .text-section-container with your section's actual selector */ .text-section-container { display: none !important; }Again, use your browser's inspect tool to find the class/ID of the section wrapping the "text" content.
Permanent removal (no trace of the section in code)
- If it's a widget: Go to Appearance → Widgets, find the "text" widget in the relevant sidebar/widget area, and delete it.
- If it's hardcoded in your theme: Add this to your child theme's
functions.php(swap out the hook and function names to match your theme):remove_action('theme_page_section_hook', 'text_section_render_function'); - If you use a page builder (like Elementor or Beaver Builder): Just open the page in the builder, find the "text" section, delete it, and save your changes. That's it!
内容的提问来源于stack exchange,提问作者Mahmut Alban

