• Resolved mrsmarshah

    (@mrsmarshah)


    I am using Thematic Framework and the child theme Power Blog. I want to add thumbnails beside the archive posts, not on the front page. This works fine. The problem I am having is that the thumbnail appears above the title instead of to the left of the text. Also, how do I make the thumbnail link to the full post?

    // Thumbnails
    add_theme_support('post-thumbnails');
    function my_post_title($title) {
        if (is_category()) {
            return get_the_post_thumbnail(NULL, 'thumbnail') . $title;
        } else {
            return $title;
        }
    }
    add_filter('thematic_postheader_posttitle', 'my_post_title');
Viewing 8 replies - 1 through 8 (of 8 total)
  • Dan Bissonnet

    (@asinglehumanbeing)

    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;
    }

    Thread Starter mrsmarshah

    (@mrsmarshah)

    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!

    Dan Bissonnet

    (@asinglehumanbeing)

    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?

    Thread Starter mrsmarshah

    (@mrsmarshah)

    Dan Bissonnet

    (@asinglehumanbeing)

    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');
    Thread Starter mrsmarshah

    (@mrsmarshah)

    ^ 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.

    Dan Bissonnet

    (@asinglehumanbeing)

    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');
    Thread Starter mrsmarshah

    (@mrsmarshah)

    Ah, sweet! Thank you soo much! This worked =D!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Post thumnail in Thematic wont wrap text’ is closed to new replies.