I am looking for a way to output some html (javascript actually) on a post view only and not on a main page, tag, category view (where WP outputs several posts).
E.g it would be output on this page
blog.yourdomain.com/2012/05/some-post/
But not on
blog.yourdomain.com/
blog.yourdomain.com/category/xxx/
blog.yourdomain.com/tag/yyy/
etc.
The HTML to be output is different for each post
If you want to load your js only on page/post view you can do it like this:
Eugene’s answer was a little over complex for my needs so here’s what I did (though +1 to Eugene as it got me looking in the right places)
I first added a custom field called singlePostHTML to the posts that I wanted to add script to – put the script in the value.
WordPress – Using Custom Fields
I then edited single.php (as this template is used only when you’re only displaying a single post, rather than multiple posts on home page or archive/category/search views).
WordPress – template hierarchy
And added the following