Navigation überspringen

[Gelöst] Tell Google about adult pages

This support ticket is created vor 1 year, 8 months. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 5 Antworten, hat 3 Stimmen.

Zuletzt aktualisiert von Minesh vor 1 year, 8 months.

Assistiert von: Minesh.

Author
Artikel
#2749426

Hi,

We publish art (specific post type) on our website, and some of it may contain nudity.

We want to make sure that not the whole website will be blocked by safesearch on Google. So we only want to mark these specific art pages by using this guide:
versteckter Link

Is this possible with toolset, and how should I do that?

#2749545

Mateus Getulio
Unterstützer

Sprachen: Englisch (English )

Zeitzone: America/Sao_Paulo (GMT-03:00)

Hello there,

While there's no specific bultin function I can think off within Toolset, it is easy to implement something like that with a little custom code.

First, for your CPT art, you can add a new boolean custom field, eg.: 'explicit_content'. Then for the posts you want to add the adult meta tags you mark that field to be true.

Then you can use a code similar to this to check if it is from the CPT art and if the field explicit_content is true to add the needed meta tags as indicated by Google:

function add_safesearch_meta_tag() {
    if ( is_singular('art') ) { // 'art' is the CPT slug
        $explicit_content = get_post_meta(get_the_ID(), 'explicit_content', true); // Replace 'explicit_content' with your field slug
        if ( $explicit_content ) {
            echo '<meta name="rating" content="adult">';
        }
    }
}
add_action('wp_head', 'add_safesearch_meta_tag');

You can add it to your theme's functions.php file or to the Toolset Settings > Code Snippets.

The code is meant to nudge you in the right direction, you might need to adapt it to your own scenario and review the needed meta tags for Google to properly classify those items.

Thank you,
Mateus

#2750690
Schermafbeelding 2024-09-21 191236.png
Schermafbeelding 2024-09-21 190556.png

Thank a lot! Unfortunately i'm absolutely not good with coding. But I made an 18 + checkbox within the post field group and that works . the field slug is: 18-plus and the singular slug for art is: Kunstwerk
So if i add this code, would that be sufficient?:

function add_safesearch_meta_tag() {
if ( is_singular('Kunstwerk') ) { // 'art' is the CPT slug
$explicit_content = get_post_meta(get_the_ID(), '18-plus', true); // Replace 'explicit_content' with your field slug
if ( $explicit_content ) {
echo '<meta name="rating" content="adult">';
}
}
}
add_action('wp_head', 'add_safesearch_meta_tag');

#2754106

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Can you please try to use the following code and try to resolve your issue:

function add_safesearch_meta_tag() {
if ( is_singular('kunstwerk') ) { // 'art' is the CPT slug
$explicit_content = get_post_meta(get_the_ID(), 'wpcf-18-plus', true); // Replace 'explicit_content' with your field slug
if ( $explicit_content ) {
echo '<meta name="rating" content="adult">';
}
}
}
add_action('wp_head', 'add_safesearch_meta_tag');
#2758049

Yes that works!

This line is added to the source code of the 18+ pages:

</noscript><meta name="rating" content="adult"><style id='wp-fonts-local'>

Is that what you expected the code to do?

#2758058

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Yes as suggested with the Doc:
- versteckter Link

It should add the following line of the code:
<codde>
<meta name="rating" content="adult">
[/php]

#2758069

You're the best! Thanks a lot