Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Montezuma Theme »

Featured image showing in header - possible?


  #1  
Old Oct 2, 2012, 03:37 PM
furiousfrog
 
23 posts · May 2009
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?
  #2  
Old Oct 2, 2012, 04:27 PM
juggledad's Avatar
juggledad
 
23,655 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Oct 3, 2012, 01:13 AM
furiousfrog
 
23 posts · May 2009
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

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Featured Image NOT showing up in from the page anymore? Luis Lecca Post-Kicker, -Byline & -Footer 4 Feb 2, 2012 11:14 AM
Featured image won't resize Pierre Excerpts, Read more, Pagination 5 Jan 31, 2011 09:13 AM
[SOLVED] Header Image not showing socalfusions Header configuration & styling 1 Jul 25, 2010 12:40 AM
Can i have more than one image showing in my header at one time kimkitch Header configuration & styling 4 May 31, 2010 10:56 AM
[SOLVED] Header image not showing ellie Header configuration & styling 6 Oct 29, 2009 11:05 AM


All times are GMT -6. The time now is 08:16 AM.


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