Is
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'helio_slider', array('class' => 'slidimg') );
}
being called within the loop?
If not, try this:
if ( has_post_thumbnail( $post->ID ) ) {
echo get_the_post_thumbnail( $post->ID, 'helio_slider', array('class' => 'slidimg') );
}
didn’t work.
No matter what theme I use, unless I put in a custom script they can never sem to find my damned thumbnails. The image will show in the article just fine… but no thumbnail
I just tried again with a fresh install of wordpress on a brand new domain. Same problem.
Does ‘has_post_thumbnail()’ fail if the folder is named something other than ‘wordpress’?
As a core function, has_post_thumbnail() should find your uploads directory just fine.
Are you able to turn debug on? Maybe there’s some strange disconnect happening… http://codex.wordpress.org/Editing_wp-config.php#Debug
Alternatively, what if you replace $post->ID with an known ID, and add an else statement?
$id = 'known-id';
if ( has_post_thumbnail( $id ) ) {
echo get_the_post_thumbnail( $id, 'helio_slider', array('class' => 'slidimg') );
} else {
echo 'did not pass the has_post_thumbnail() check';
}
nope. Even forcing an ID=1 failed.
If it was something in the theme code, it wouldn’t be happening with every theme except ones I build myself so it must be something in how my wordpress install is configured.
But this is a clean-sheet configuration, and the only thing I’ve customized is to set appearance to this theme, and it happens with me 4 other wordpress installs to. So it must be something in the code.
This makes no sense *headdesk*
so I gave up on the shorter, elegant code that doesn’t work and used the longer, ham-fisted but functional method from my previous themes
function slide_image($postid=0, $size='thumbnail') {
if ($postid<1) $postid = get_the_ID();
if ($images = get_children(array(
'post_parent' => $postid,
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image',
'order_by' => 'menu_order',
'order' => 'ASC')))
foreach($images as $image) {
$attachment=wp_get_attachment_image_src($image->ID, $size);
?><img src="<?php echo $attachment[0]; ?>" class="slidimg" /><?php
} else {
?>
<img class="slidimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.jpg" />
<?php
};
}
now my question is how do I tell it which image to use? When you upload an image with a theme that has a custom size for a window or accordion on the index page, it’ll upload a thumbnail, a small, a medium, a large, a full, and a custom version of the image to the Uploads folder.
example: Uploading test.jpg results in multiple files
test.jpg
test-150×150.jpg
test-200×150.jpg
test-300×225.jpg
test-621×250.jpg
Right now, as you can see, I’m calling the thumbnail version – because I don’t know what the -621×250 version would be called.
I think you’d use helio_slider – whatever the name is you assigned it in the functions.php file.
I’m kind of intrigued by the original issue though – would it be possible post the problem code in context (perhaps via http://pastebin.com/ or http://codepad.org/)? I’d toss it up on my test site to see if there’s anything funky going on…
not sure how to post code ‘in context’ when it’s php files calling each other all over the place
Sorry about the delay in responding – about half way through this note I lost my internet connection… Long story short, I’m working from my phone…
****
In my functions.php
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150 );
add_image_size( '300-square', 300, 300, true );
in index.php, outside of the loop:
<?php
if (has_post_thumbnail( $post->ID )) {
echo '<div style="text-align:center;padding:20px; background:#bbb;">';
echo get_the_post_thumbnail( $post->ID , '300-square');
echo '</div>';
}
?>
in index.php, inside the loop:
<?php
if (has_post_thumbnail()) {
echo '<div style="text-align:center;padding:20px; background:#bbb;">';
the_post_thumbnail('300-square');
echo '</div>';
}
?>
functions.php
index.php
live test site
Sorry trepmal, I didn’t see your reply until now.
I very much appreciate all your help. I still don’t know why virtually every theme I try doesn’t show thumbnails unless I go in and alter the code. Obviously this isn’t the case for everyone – themes wouldn’t be released with thumbnails broken across the board.