Support » Plugins and Hacks » Posts By Tag » Thumnails linked to post

  • Resolved Borko

    (@media-x)


    Hi Sudar!

    Was tryin’ to find a place where i could see your plugin in action. The thing is that i can’t seem to get the thumbnails link to the posts. I checked the php code in charge for that and it looks just fine. Using the latest version of the plugin.

    if ($thumbnail) {
                        if (has_post_thumbnail($tag_post->ID)) {
                            $output .= get_the_post_thumbnail($tag_post->ID, 'thumbnail');
                        } else {
                            if (get_post_meta($tag_post->ID, 'post_thumbnail', true) != '') {
                                $output .=  '<a class="thumb" href="' . get_permalink($tag_post) . '" title="' . get_the_title($tag_post->ID) . '"><img src="'. esc_url(get_post_meta($tag_post->ID, 'post_thumbnail', true)) . '" alt="' . get_the_title($tag_post->ID) . '" ></a>';
                            }
                        }
                    }

    Check the 2 boxes bellow the slider here. Thanks in advance!

    http://wordpress.org/extend/plugins/posts-by-tag/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Sudar Muthu

    (@sudar)


    I need the following information

    – How are you using the Plugin? Widget, shortcode or template function?
    – Have you enabled the thumbnail option?
    – Does your posts have a featured image?

    I’m using the widget,thumbnail enabled,post have the featured image. Everything is working just fine,except the permalink for the image.

    Tested it on a clean WP install, with default Twenty Twelve theme, no active plugins and it doesn’t work either.

    Plugin Author Sudar Muthu

    (@sudar)


    Okay I know why it is not working now.

    I am using this function to get the featured image http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail and it is just printing the image instead of linking it.

    I am working on a fix for this. You can track the progress here https://github.com/sudar/posts-by-tag/issues/2

    This works:

    if ($thumbnail) {
                        if (has_post_thumbnail($tag_post->ID)) {
                            $output .= '<a href="' . get_permalink( $tag_post->ID ) . '" title="' . esc_attr( $tag_post->post_title ) . '">'. get_the_post_thumbnail($tag_post->ID, 'thumbnail') . '</a>';
                        } else {
                            if (get_post_meta($tag_post->ID, 'post_thumbnail', true) != '') {
                                $output .=  '<a class="thumb" href="' . get_permalink($tag_post) . '" title="' . get_the_title($tag_post->ID) . '"><img src="'. esc_url(get_post_meta($tag_post->ID, 'post_thumbnail', true)) . '" alt="' . get_the_title($tag_post->ID) . '" ></a>';
                            }
                        }
                    }

    The code should be cleaned. This is just a draft. But it works.

    Plugin Author Sudar Muthu

    (@sudar)


    Yes, this should work. Would you be interested in submitting a pull request at github?

    Here we go. posts-by-tag.php @ app. line 728
    I replaced this:

    if ($thumbnail) {
                        if (has_post_thumbnail($tag_post->ID)) {
                            $output .= get_the_post_thumbnail($tag_post->ID, 'thumbnail');
                        } else {
                            if (get_post_meta($tag_post->ID, 'post_thumbnail', true) != '') {
                                $output .=  '<a class="thumb" href="' . get_permalink($tag_post) . '" title="' . get_the_title($tag_post->ID) . '"><img src="'. esc_url(get_post_meta($tag_post->ID, 'post_thumbnail', true)) . '" alt="' . get_the_title($tag_post->ID) . '" ></a>';
                            }

    with this:

    if ($thumbnail) {
                        if (has_post_thumbnail($tag_post->ID)) {
                            $output .= '<a href="' . get_permalink( $tag_post->ID ) . '" title="' . esc_attr( $tag_post->post_title ) . '">'. get_the_post_thumbnail($tag_post->ID, 'thumbnail') . '</a>';
                        }

    Please,can you handle the github part?

    Regards

    Plugin Author Sudar Muthu

    (@sudar)


    We should handle the other case as well.

    I have made the required code change. You can look at it at https://github.com/sudar/posts-by-tag/commit/d2d5a3131bfc9ca55435bf5177f8d102dcc4e051

    This will get released in v2.8 of the Plugin.

    Marking this thread as resolved. Reopen if you still face any issues.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Thumnails linked to post’ is closed to new replies.