It’s too late to reply to the person who wrote a bad review because this only works on pages (which is in the title of the plugin, so no surprise).
So… currently, it doesn’t work on anything. It does not appear to be compatible with the block editor.
Here’s what I wrote after looking at the code, before I realized this does not work in modern WP
—————–
But this is a VERY simple plugin. You could easily fork it or just assume the developer will not update it, given that it has been seven years. But all you would need to do is find these lines at the top of noindex-pages.php
// Filterable list of post types which will show the checkbox and add the meta tag
function noinp_post_types() {
return apply_filters( 'noindex-pages-post-types', array( 'page' ) );
}
And change the array definition to include whatever post types you want like
array ('page', 'post', 'my-custom-content-type')
Haven’t tried it, but looking at the rest of the code, both the save and display functions are simply checking against that array, so it should work just fine.
Security
Another review asked about security. I was worried about this too given how old it is. The only allowed user input is to check or not the checkbox when a post is saved, so there is no real opportunity for a brute force or XSS attack against this as far as I can see.
Future compatibility
Because this is so simple, there’s not much here. I checked this with Rector against PHP 7.4. and PHP 8.1 and there were no flags. This code works with current versions of PHP as of 2023.
I did not check the WP API functions, but it uses only the most basic functions like wp_enqueue_style() or get_post_type().
So despite the age of this plugin and the lack of support, I have no reservations about using it and I very much like how light it is – simple plugin that does one thing and one thing only.
]]>When I check the box for blog posts and publish it, the box gets unchecked again. Automatically. Over and over again. Nothing I can do about it, and there’s no way to get the noindex code added to the post.
]]>Hello,
I installed your plugin, added the extra code to the functions.php so it will also be added to “posts.”
Now the box shows up on post pages, but the box will not stay “checked” after we update the post.
Please help.
]]>Hello,
I was using this on a site while it was in development. If i simply uninstall the plugin will the tags be removed?
thank you
]]>Hi,
Good plugin. Very handy.
However, in WooCommerce, when we go to an “Edit product page” for any given product, and then we check the checkbox at “Hide from search engines” on the right-hand side of the Edit product page, the checkbox becomes unchecked again when we then click on “Update.”
Is there a way to get it to work with WooCommerce product pages?
Thanks.
]]>Currently the meta box gets shown for every post type, not just the supported ones.
You need to add
if ( !in_array( $post->post_type, noinp_post_types() ) ) return;
to noinp_display_meta_checkbox()
to fix this.