Ambrosite Next/Previous Post Link Plus
[resolved] Place thumb image inside link format. %thumb? (3 posts)

  1. jpsingleton
    Posted 1 year ago #

    Is there a way to insert the thumb image into the same link as the text, so there is only one link tag?

    If I could use %thumb to place the thumbnail image within the link, that would be perfect. Is there any way to make this happen?



  2. jpsingleton
    Posted 1 year ago #

    For example:

    $nextPostFormat = '%link';
    $nextPostLink = '%thumb<span class="direction">Next <span class="arrow">▶</span></span><span class="next_title">%title</span>';
    next_post_link_plus( array(
    	'thumb' 		=> 'medium',
    	'format' 		=> $nextPostFormat,
    	'link'			=> $nextPostLink,
  3. ambrosite
    Plugin Author

    Posted 1 year ago #

    It's possible if you are willing to hack the plugin code. You need to find these lines (368-373 in version 2.4):

    if ( $r['thumb'] && has_post_thumbnail($post->ID) ) {
        if ( $r['thumb'] === true )
            $r['thumb'] = 'post-thumbnail';
        $thumbnail = '<a class="post-thumbnail" href="'.get_permalink($post).'" rel="'.$rel.'"'.$tooltip.'>' . get_the_post_thumbnail( $post->ID, $r['thumb'] ) . '</a>';
        $format = $thumbnail . '<span class="post-link">' . $format . '</span>';

    Replace them with this:

    if ( $r['thumb'] && has_post_thumbnail($post->ID) ) {
        if ( $r['thumb'] === true )
            $r['thumb'] = 'post-thumbnail';
        $thumbnail = get_the_post_thumbnail( $post->ID, $r['thumb'] );
        $format = str_replace('%thumb', $thumbnail, $format);

    I have not tested this code but I think it should work.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic