To make the thumbnail link to the post try:
return '<a class="post-thumbnail-link" href="'.get_permalink().'">'.get_the_post_thumbnail(NULL, 'thumbnail').'</a>' . $title;
The post title is usually wrapped in a h1 or h2 which is probably what is causing it to display on a new line instead of next to the thumbnail. You’ll need to adjust the CSS for the thumbnail to make them float next to each other.
Something like this in your style.css might work depending on your existing styling:
.post-thumbnail-link {
float:left;
}
The alignment issue is still unresolved. I tried editing in css, the alignment works (I floated it right just to check it out) but it will not wrap the text. It’s still appearing directly above the title. I’m not sure how to fix it.
Thank you so very much for the code to link the thumbnail to the full post. I am very grateful!
You’re welcome.
There could be other CSS rules that are interfering with the layout. Have you got a live version of the page that I could look at?
Ok, thanks. Looking at it, I think it’s probably better to put the thumbnail within the post title and then float it. Here’s a replacement for your function which should do the job. You won’t need any extra styling as the theme has an alignleft class which does the work for you:
function my_post_title($posttitle) {
if (is_single() || is_page()) {
$posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
} elseif (is_404()) {
$posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
} elseif (is_category()) {
$posttitle = '<h2 class="entry-title">';
$posttitle .= '<a class="alignleft" href="'.get_permalink().'">'.get_the_post_thumbnail(NULL, 'thumbnail').'</a>'
$posttitle .= '<a href="';
$posttitle .= get_permalink();
$posttitle .= '" title="';
$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
$posttitle .= '" rel="bookmark">';
$posttitle .= get_the_title();
$posttitle .= "</a></h2>\n";
} else {
$posttitle = '<h2 class="entry-title"><a href="';
$posttitle .= get_permalink();
$posttitle .= '" title="';
$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
$posttitle .= '" rel="bookmark">';
$posttitle .= get_the_title();
$posttitle .= "</a></h2>\n";
}
return $posttitle;
}
add_filter('thematic_postheader_posttitle', 'my_post_title');
^ Really appreciate your help. I got a white screen when I put the code in my functions file. After that I tried to mess around with the code a little but I still couldn’t make it work. I am pretty new to PHP so to me your code looks brilliant but I haven’t the knowledge to see where it breaks down.
Sorry – missed a semicolon. Try this:
function my_post_title($posttitle) {
if (is_single() || is_page()) {
$posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
} elseif (is_404()) {
$posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
} elseif (is_category()) {
$posttitle = '<h2 class="entry-title">';
$posttitle .= '<a class="alignleft" href="'.get_permalink().'">'.get_the_post_thumbnail(NULL, 'thumbnail').'</a>';
$posttitle .= '<a href="';
$posttitle .= get_permalink();
$posttitle .= '" title="';
$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
$posttitle .= '" rel="bookmark">';
$posttitle .= get_the_title();
$posttitle .= "</a></h2>\n";
} else {
$posttitle = '<h2 class="entry-title"><a href="';
$posttitle .= get_permalink();
$posttitle .= '" title="';
$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
$posttitle .= '" rel="bookmark">';
$posttitle .= get_the_title();
$posttitle .= "</a></h2>\n";
}
return $posttitle;
}
add_filter('thematic_postheader_posttitle', 'my_post_title');
Ah, sweet! Thank you soo much! This worked =D!