Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Montezuma Theme (http://forum.bytesforall.com/forumdisplay.php?f=53)
-   -   Featured image showing in header - possible? (http://forum.bytesforall.com/showthread.php?t=18543)

furiousfrog Oct 2, 2012 03:37 PM

Featured image showing in header - possible?
 
Hi there,

Love the theme - have managed to insert a logo instead of the title, but am trying to show the featured image in the header.

This is what I've added to the header.php sub-template:

<?php
if(has_post_thumbnail()){
echo '<div class="other-image-header">';
the_post_thumbnail('full');
echo '</div>';
}
else{
echo '<div class="default-image-header"></div>';
}
?>

and put this in various.css:

.default-image-header {
display: block;
width: 404px;
height: 202px;
background: url("%tpldir%/images/home.png");
}

.other-image-header {
width: 404px;
height: 202px;
}



Yet, for some reason I just can't get "the_post_thumbnail" to display, despite trying various iterations. Would love some advice on where I'm going wrong, or even a pointer in the right direction?

juggledad Oct 2, 2012 04:27 PM

you can't access post information untill you are in 'The LOOP' and the featured image is part of a post. You can do it, it just you will have to code a wp-query. It might be much easier to find a plugin that would do it for you.

furiousfrog Oct 3, 2012 01:13 AM

Hi Juggledad,

I did wonder if that was the case - saw something similar in the codex, but there seemed to be lots of tutorials on the net suggesting that you could just place the query in the header!

Thanks for the reply, much appreciated. I'm trying to improve my abysmal php knowledge but I do think a plugin would be better in the first instance - I can always pick that apart!

Cheers,

ff


All times are GMT -6. The time now is 05:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.