Adding meta name=”rating” tags — how?

[ad_1]

In your themes functions.php file, or in a new plugin that you create for this, you can add in this code:

function set_adult_rating() {
    echo '<meta name="rating" content="adult">';
}

add_action( 'wp_head', 'set_adult_rating' );

Wow, that actually worked. Thanks!

By the way, my 2023 theme directory doesn’t have a functions.php file, so I appended it to wp-includes/footer.php file. Is it possible that this file will be overwritten in a future WP update?

Is it possible that this file will be overwritten in a future WP update?

100% yes.

The best option might be to create a small plugin file for that, and just use that instead. It will do the same job, just needs a tiny bit more coding.

<?php
/**
 *  Plugin Name: Add adult meta tag
 */

function set_adult_rating() {
    echo '<meta name="rating" content="adult">';
}

add_action( 'wp_head', 'set_adult_rating' );

Save that as a new file, and upload that to your plugins folder. Then activate it and it will do the same thing, with no worry about it being over-written.

Oh, and don’t forget to remove the code from your footer file. 🙂

Thanks, while you were typing your comment, I was reading around and about to reach the same conclusion. A site-specific plugin seems like the perfect way to do this… Once again, this helped a lot!

  • This reply was modified 6 minutes ago by rjnagle.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer