Site logo

[Resolved] Post navigation thumbnails clickable with link

Home Forums Support [Resolved] Post navigation thumbnails clickable with link

Home Forums Support Post navigation thumbnails clickable with link

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1677248
    Michel

    Hi,

    I use the following code for previous/next navigation in single posts.

    add_filter( 'generate_post_navigation_args', function( $args ) {
        if ( is_single() ) {
            $prevPost = get_previous_post(true);
            $prevThumbnail = isset( $prevPost ) ? get_the_post_thumbnail( $prevPost->ID ) : '';
            $nextPost = get_next_post(true);
            $nextThumbnail = isset( $nextPost ) ? get_the_post_thumbnail( $nextPost->ID ) : '';
    
            $args['previous_format'] = '<div class="nav-previous">Previously:<br>' . $prevThumbnail . '<br><span class="prev" title="' . esc_attr__( 'Previous', 'generatepress' ) . '">%link</span></div>';
            $args['next_format'] = '<div class="nav-next">Next:<br>' . $nextThumbnail . '<br><span class="next" title="' . esc_attr__( 'Next', 'generatepress' ) . '">%link</span></div>';
        }
    
        return $args;
    } );

    One thing eludes me: making the thumbnail clickable with the next/previous link. How can that function add it?

    #1677707
    Michel

    Is there any chance to find a tip regarding this?

    #1677741
    Leo
    Staff
    Customer Support

    Hi Michel,

    Have you considered using GPP 2.0 which is in the Alpha version currently?

    The block element now allows you to design custom post navigation without any coding at all.

    See the Post Navigation Templates section of this article here:
    https://generatepress.com/introducing-the-gp-theme-builder/

    And more info on dynamic data and blocks:
    https://docs.generatepress.com/article/dynamic-data/
    https://docs.generatepress.com/article/dynamic-blocks/

    Please keep in mind that we reply to every question within 24 hours – most of the time it’s much shorter.

    #1677751
    Michel

    Hmmm. Haven’t made the transition to the block editor yet, and using an alpha version on a production site may be a bit much for me.

    Is there any workaround for between now and that kind of transition?

    #1678025
    Leo
    Staff
    Customer Support
    #1678463
    Michel

    This works. All I have to do now is to customise the CSS a little. Thanks! 🙂

    #1679172
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.