How to hide text from Google snippets in WordPress
To hide one passage from Google's snippets in WordPress, wrap it in an element with the data-nosnippet attribute using a Custom HTML block. To limit or remove the snippet for a whole page, set Max snippet length or No snippet in the page's SEO Settings sheet, which prints max-snippet or nosnippet in the robots tag.
The page stays indexed and can still rank with any of these. They only control what text Google may quote under the result, and Google documents that the same controls apply to AI Overviews and AI Mode.
Step by step
1. Pick the narrowest control that works
- One passage, such as a price, a spoiler or a legal notice:
data-nosnippeton that passage. - A cap on how much is quoted:
max-snippetwith a character count. - No text snippet at all for the page:
nosnippet.
Start with the narrowest. A result with no snippet gives searchers less reason to click, so page-wide limits need a concrete reason, such as paywalled text or licensing terms.
2. Wrap a passage in data-nosnippet
Google reads data-nosnippet on span, div and section elements. The block editor has no field for custom attributes, and adding one to a Paragraph block's HTML makes the block fail validation. Use a Custom HTML block instead:
<div data-nosnippet>
<p>Members pay 40 percent less. Log in to see your price.</p>
</div>
For a few words inside a sentence, use a span in the same block: <span data-nosnippet>internal code 4471</span>. In the Classic editor, switch to the Text tab and add the attribute there. WordPress keeps data- attributes when the post is saved, including for authors without the unfiltered HTML capability.
3. Keep the markup valid
Google's documentation says the attribute is treated as a boolean, so a value is not needed, and that the HTML must be valid with a closing tag for every opening one. An unclosed div can extend the hidden area further than you meant. After saving, view the page source and check that the wrapper opens and closes around the passage only.
4. Cap the snippet for one page
- Open the post and open the SEO Settings sheet (⌘E or Ctrl+E).
- Open Robots Meta.
- Switch off Snippets & previews: use site default.
- Set Max snippet length to a number of characters, for example
120.-1means no limit and0means no text snippet. - Save the post.
The robots tag on that page now includes max-snippet:120. The other pages keep the site-wide values.
5. Or remove the snippet for the page
In the same section, switch on No snippet. The length and video preview fields are disabled, because nosnippet already rules both out, and the tag carries nosnippet. Google then shows no text snippet or video preview for the page and does not use its content as direct input for AI Overviews and AI Mode. An image thumbnail may still appear.
6. Set a site-wide default only if you must
The same five fields live on Hydrogen SEO → Robots, in the Snippets & Previews card, and apply to every indexed page. The defaults are permissive: no snippet limit and large image previews. A line beginning Printed on indexed pages: shows the exact directives before they reach a page. Change these only when the rule truly applies to the whole site.
7. Verify what Google will read
Check the tag:
curl -s https://example.com/a-post/ | grep -i 'name="robots"'
For data-nosnippet, search the source for the attribute. Snippets change when Google recrawls the page, so use URL Inspection → Request indexing in Search Console if the old snippet matters.
Without the plugin
Core prints its robots tag through the wp_robots filter, so a page-level limit takes a few lines:
add_filter( 'wp_robots', function ( $robots ) {
if ( is_page( 'members-pricing' ) ) {
$robots['max-snippet'] = '120';
}
return $robots;
} );
String values are printed as directive:value. Use $robots['nosnippet'] = true; for the stricter rule. data-nosnippet needs no code or plugin either way.
What these controls do not do
They do not hide text from visitors, from the page source, or from crawlers. They do not stop the page ranking for words in the hidden passage. A meta description you wrote can still be shown unless nosnippet is set. To keep a page out of results entirely, use noindex. To keep specific crawlers away, use robots.txt, as in block AI crawlers in robots.txt.
Common questions
Does data-nosnippet affect rankings?
It is a display control. The page is still crawled and indexed in full, and the marked text is simply not quoted in the snippet.
Can I add data-nosnippet to a paragraph tag?
Google lists span, div and section as the supported elements. Wrap the paragraph in a div that carries the attribute.
Is max-snippet:0 the same as nosnippet?
Yes. Google documents that a max-snippet value of 0 is equivalent to nosnippet.