Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi there,

    Sorry I don’t understand the question at all.

    Can you explain a bit more or perhaps provide a live example for us to take a look?

    Thanks ??

    Thread Starter link1921u

    (@link1921u)

    Thread Starter link1921u

    (@link1921u)

    Try David’s solution here:
    https://generatepress.com/forums/topic/post-navigation-with-clickable-thumbnails/#post-1523670

    You can remove this line from the PHP snippet:
    add_filter( 'generate_category_post_navigation', '__return_true' );

    I’ll also mention that GP Premium 2.0 (currently in Alpha) makes this super easy to achieve:

    Thread Starter link1921u

    (@link1921u)

    Hi @leohsiang ?thanks for your code and video!

    I have one question more:

    I have this code, which makes the post navigation, only able to redirect to other posts of its same category.

    add_filter( 'generate_category_post_navigation', 'change_category_post_navigation' );
    function change_category_post_navigation()
    { 
        return true;
    }

    How could I modify the code, that you have given me, so that it only shows me the thumbnails of the posts of those categories, and not the previous post by ID

    Hi there,

    try updating the code in the link Leo provided to:

    add_filter( 'generate_post_navigation_args', function( $args ) {
      if ( is_single() ) {
          $prevPost = get_previous_post();
          $prevThumbnail = isset( $prevPost ) ? get_the_post_thumbnail( $prevPost->ID, 'thumbnail' ) : '';
          $nextPost = get_next_post();
          $nextThumbnail = isset( $nextPost ) ? get_the_post_thumbnail( $nextPost->ID, 'thumbnail' ) : '';
    
          $args['in_same_term'] = true;
          $args['previous_format'] = '<div class="nav-previous">' . $prevThumbnail . '<div class="post-title-wrap"><span class="title-label">Previous Post</span><span class="prev" title="' . esc_attr__( 'Previous', 'generatepress' ) . '">' . generate_get_svg_icon( 'arrow-left' ) .'%link</span></div></div>';
          $args['next_format'] = '<div class="nav-next"><div class="post-title-wrap"><span class="title-label">Next Post</span><span class="next" title="' . esc_attr__( 'Next', 'generatepress' ) . '">%link ' . generate_get_svg_icon( 'arrow-right' ) . '</span></div>' . $nextThumbnail . '</div>';
      }
    
      return $args;
    } );
    
    add_filter( 'generate_category_post_navigation', '__return_true' );

    The only change is the addition of this line:

    $args['in_same_term'] = true;

    Thread Starter link1921u

    (@link1921u)

    Hi @diggeddy I tried your code, but it didn’t work, i don’t know why but nothing changes.

    I have this in my shortcode:

    https://ibb.co/7jR3b2B

    Oops… sorry about that. Change this:

    $prevPost = get_previous_post(); to: $prevPost = get_previous_post(true);

    and

    $nextPost = get_next_post(); to: $nextPost = get_next_post(true);

    Thread Starter link1921u

    (@link1921u)

    @diggeddy You and @leohsiang are amazing!!!!! Thanks!!! It works!!!

    Awesome – glad to hear that!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Post Navegation with image’ is closed to new replies.