- How can I place featured images into the header, so each post has it's featured image within the main header?
- Also on category archive pages and the main news page, the featured images are being used in the traditional way, using the custom post image so is there a way around that too, where I can use the featured image for both posts and header.
- Maybe there is a way of having two custom thumbnail images and calling one up for the featured image and the other for the header?
1 Answer
Your question is confusing but I'll try.
Item 1
The $post
variable is set before the template loads. It is preset to the first post in the Loop by the main query, so on single post/pages it matches the post/page that you are on and you can use it in the header to display your thumbnail.
Item 2
This is the most confusing of your questions. I am not really sure what you want. Again, the $post
variable is set before the template loads. You could use that to display the thumbnail from the first post in the results in the header of the page. You would be using "the featured image for both posts and header" but there are potentially multiple thumbnails on a category archive so I am not sure that is what your really want.
Item 3
By default, there is not way to do this, but it pretty easy to have multiple featured images by way of custom meta fields.
See also: https://wordpress.stackexchange.com/a/109468/21376 A synopsis of that link: Trusting $post
out of Loop context is a bit dicey unless you really understand WordPress template rendering internals. Using a function called get_queried_object
can help get more expected behavior.
-
Thanks for having a go at answering my question, if you have a look at the HTML5Boilerplate-Starkers-WordPress-Theme on github bit.ly/19akA4B it answers my problems and probably explains what I was on about.– NsokyiAug 10, 2013 at 17:55