Joy
(@joyously)
Easiest way is to use a plugin that does it already.
Other way is to write a plugin (can be small) that calls add_action for ‘wp_head’ to output the information.
Adding to what Joy said, “wp_head” fires outside of the Loop. We can customarily only determine specific post data within the Loop. As it happens, if is_single() returns true, the requested post object seems to be already assigned to global $post. It would be a good idea to verify it’s assigned an object before attempting to use it. If it is not set for some reason, the requested object can be had with get_queried_object(). This function does not necessarily return a post object, so confirm it’s a WP_Post object before trying to use it as such.
I need this function too. I need to have certain pages noindex and no plugin has been able to do it even though they all say they can.
I saw an article that in Sept Google is changing what will be acceptable to noindex so I am of the mind that if the plugins do not work now, what will happen when Sept rolls around?
So I am left with the prospect of individually going in an coding each page myself! But at least then I will know it’s done and won’t suddenly not work because a plugin was doing it the unacceptable way (if I could even get one to work now). Not a happy camper at all!
BUT cannot find how to access the actual html of a Page. NOT a universal header change! I certainly don’t want to noindex my entire site!
Is there any hope for me, a non-geek?