WordPress.org

Ready to get started?Download WordPress

Forums

Posts By Tag
[resolved] Thumnails linked to post (9 posts)

  1. Media X
    Member
    Posted 1 year ago #

    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/

  2. Sudar
    Member
    Plugin Author

    Posted 1 year ago #

    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?

  3. Media X
    Member
    Posted 1 year ago #

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

  4. Media X
    Member
    Posted 1 year ago #

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

  5. Sudar
    Member
    Plugin Author

    Posted 1 year ago #

    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

  6. Media X
    Member
    Posted 1 year ago #

    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.

  7. Sudar
    Member
    Plugin Author

    Posted 1 year ago #

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

  8. Media X
    Member
    Posted 1 year ago #

    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

  9. Sudar
    Member
    Plugin Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic