Title: add code to head section at post level
Last modified: January 21, 2019

---

# add code to head section at post level

 *  [charlie101](https://wordpress.org/support/users/charlie101/)
 * (@charlie101)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/add-code-to-head-section-at-post-level/)
 * I want to add some Schema.org code to my website, which should go in the HEAD
   section. However the Schema.org code is different across different posts (and
   some posts won’t have this particular Schema code at all.) As such I can’t just
   use WP-INSERT to copy and paste code across all posts and pages.
 * What’s the easiest way of adding different code to HEAD section that I can change
   depending on the post?
 * Cheers

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/add-code-to-head-section-at-post-level/#post-11114118)
 * 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.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/add-code-to-head-section-at-post-level/#post-11114899)
 * 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.
 *  [22carol](https://wordpress.org/support/users/22carol/)
 * (@22carol)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/add-code-to-head-section-at-post-level/#post-11748079)
 * 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?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘add code to head section at post level’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [head](https://wordpress.org/support/topic-tag/head/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 4 participants
 * Last reply from: [22carol](https://wordpress.org/support/users/22carol/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/add-code-to-head-section-at-post-level/#post-11748079)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
