Add Code To Head Section At Post Level
Maybe your like
Forums
- Welcome to Support
- Guidelines
- Get involved
- Log in
- Welcome to Support
- Guidelines
- Get involved
- Log in
Forums / Developing with WordPress / add code to head section at post level
Search for: Search forums-
charlie101
(@charlie101)
6 years, 11 months ago
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
-
Joy
(@joyously)
6 years, 11 months ago
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.
Moderatorbcworkz
(@bcworkz)
6 years, 11 months ago
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
(@22carol)
6 years, 5 months ago
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?
The topic ‘add code to head section at post level’ is closed to new replies.
Tags
- code
- head
- In: Developing with WordPress
- 3 replies
- 4 participants
- Last reply from: 22carol
- Last activity: 6 years, 5 months ago
- Status: not resolved
Topics
Topics with no replies
Non-support topics
Resolved topics
Unresolved topics
All topics
Tag » Add Data To Head Section Wordpress
-
Add Code To Headers – Support
-
How To Add Code To Head Tag In Wordpress ? - Mr. Virk Media
-
Comment Ajouter Du Code à L'en-tête Et Au Pied De Page De WordPress
-
How To Insert Code Into The Head Section Of Your WordPress Blog
-
Head Meta Data - Plugins
-
How To Add Header And Footer Code In WordPress (the Easy Way)
-
How To Add Tracking Code In The WordPress Website Head Section
-
How To Easily Add Code To Your Header And Footer In WordPress
-
How To Add Meta Tags To WordPress - GreenGeeks
-
Php - How Can I Add Meta Data To The Head Section Of The Page From ...
-
How To Add Meta Tags In WordPress - HubSpot Blog
-
Adding Code Into The "head" Section Of Your Website - YouTube
-
How To Add Meta Tags To WordPress Head - YouTube
-
How To Add Code To Your WordPress Header - Namecheap Blog