New Landing How can we help? Cardinal Next/Prev article thumbnail

Viewing 9 posts - 1 through 9 (of 9 total)
  • Posted in: Cardinal
  • #172037
    akimad
    Member
    Post count: 57

    Hi,

    Actually, in the pagination section of a post page, I’ve the title, the author and the categories of the next and the prev post.

    How can I display the thumbnail too ?

    Thank you in advance for your response.

    #172077
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Can you provide a screenshot and the url to an example page?
    Thanks

    -Rui

    #172079
    akimad
    Member
    Post count: 57

    Here is a screenshot.

    The page is password restricted, if you want see the page, I can send you the credentials. But with the screenshot I think it’s not necessary.

    Attachments:
    You must be logged in to view attached files.
    #172084
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    I’m afraid that customisation is beyond our scope of support as it requires quite a bit of work, editing theme files, adjust layout, restyling etc

    – Kyle

    #172090
    akimad
    Member
    Post count: 57

    It’s not a problem for me, I’m developer.

    Can you indicate me the appropriate files to modify please ?

    I think it’s only get the thumbnail in php, at the same time to getting the title, etc.

    #172092
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Add this to your child theme functions.php file, and add your code:

      /* POST PAGINATION
        ================================================== */
        if ( ! function_exists( 'sf_post_pagination' ) ) {
    		function sf_post_pagination() {
    		    global $sf_options, $sf_sidebar_config;
    
    		    $single_author    = $sf_options['single_author'];
    		    $remove_dates     = $sf_options['remove_dates'];
    		    $pagination_style = "standard";
    		    if ( isset( $sf_options['pagination_style'] ) ) {
    		        $pagination_style = $sf_options['pagination_style'];
    		    }
    
    		    $prev_post = get_next_post();
    		    $next_post = get_previous_post();
    		    $has_both  = false;
    
    		    if ( sf_theme_opts_name() == "sf_joyn_options" && $pagination_style == "fs-arrow" ) {
    		        return;
    		    }
    
    		    if ( ! empty( $next_post ) && ! empty( $prev_post ) ) {
    		        $has_both = true;
    		    }
    		    ?>
    
    		    <?php if ( ! empty( $next_post ) || ! empty( $prev_post )) { ?>
    		    <?php if ($has_both) { ?>
    		    <div class="post-pagination-wrap prev-next">
    		    <?php } else { ?>
    		    <div class="post-pagination-wrap">
    		        <?php } ?>
    
    		        <div class="container">
    
    		            <?php if ( ! empty( $next_post ) ) {
    		                $author_id       = $next_post->post_author;
    		                $author_name     = get_the_author_meta( 'display_name', $author_id );
    		                $author_url      = get_author_posts_url( $author_id );
    		                $post_date       = get_the_date();
    		                $post_date_str   = get_the_date('Y-m-d');
    		                $post_categories = get_the_category_list( ', ', '', $next_post->ID );
    		                ?>
    		                <div class="next-article">
    		                    <h6><?php _e( "Next Article", 'swiftframework' ); ?></h6>
    
    		                    <h2>
    		                        <a href="<?php echo get_permalink( $next_post->ID ); ?>"><?php echo $next_post->post_title; ?></a>
    		                    </h2>
    		                    <?php if ( $single_author && ! $remove_dates ) { ?>
    		                        <div
    		                            class="blog-item-details"><?php echo sprintf( __( 'In %1$s on <time datetime="%2$s">%3$s</time>', 'swiftframework' ), $post_categories, $post_date_str, $post_date ); ?></div>
    		                    <?php } else if ( ! $remove_dates ) { ?>
    		                        <div
    		                            class="blog-item-details"><?php echo sprintf( __( '<span class="author">By <a href="%2$s" rel="author" itemprop="author">%1$s</a></span> in %3$s on <time datetime="%4$s">%5$s</time>', 'swiftframework' ), $author_name, $author_url, $post_categories, $post_date_str, $post_date ); ?></div>
    		                    <?php } else if ( ! $single_author ) { ?>
    		                        <div
    		                            class="blog-item-details"><?php echo sprintf( __( '<span class="author">By <a href="%2$s" rel="author" itemprop="author">%1$s</a></span> in %3$s', 'swiftframework' ), $author_name, $author_url, $post_categories ); ?></div>
    		                    <?php } ?>
    		                </div>
    		            <?php } ?>
    
    		            <?php if ( ! empty( $prev_post ) ) {
    		                $author_id       = $prev_post->post_author;
    		                $author_name     = get_the_author_meta( 'display_name', $author_id );
    		                $author_url      = get_author_posts_url( $author_id );
    		                $post_date       = get_the_date();
    		                $post_date_str   = get_the_date('Y-m-d');
    		                $post_categories = get_the_category_list( ', ', '', $prev_post->ID );
    		                ?>
    		                <div class="prev-article">
    		                    <h6><?php _e( "Previous Article", 'swiftframework' ); ?></h6>
    
    		                    <h2>
    		                        <a href="<?php echo get_permalink( $prev_post->ID ); ?>"><?php echo $prev_post->post_title; ?></a>
    		                    </h2>
    		                    <?php if ( $single_author && ! $remove_dates ) { ?>
    		                        <div
    		                            class="blog-item-details"><?php echo sprintf( __( 'In %1$s on <time datetime="%2$s">%3$s</time>', 'swiftframework' ), $post_categories, $post_date_str, $post_date ); ?></div>
    		                    <?php } else if ( ! $remove_dates ) { ?>
    		                        <div
    		                            class="blog-item-details"><?php echo sprintf( __( '<span class="author">By <a href="%2$s" rel="author" itemprop="author">%1$s</a></span> in %3$s on <time datetime="%4$s">%5$s</time>', 'swiftframework' ), $author_name, $author_url, $post_categories, $post_date_str, $post_date ); ?></div>
    		                    <?php } else if ( ! $single_author ) { ?>
    		                        <div
    		                            class="blog-item-details"><?php echo sprintf( __( '<span class="author">By <a href="%2$s" rel="author" itemprop="author">%1$s</a></span> in %3$s', 'swiftframework' ), $author_name, $author_url, $post_categories ); ?></div>
    		                    <?php } ?>
    		                </div>
    		            <?php } ?>
    
    		        </div>
    
    		    </div>
    		    <?php } ?>
    
    		<?php
    		}
        	add_action( 'sf_post_after_article', 'sf_post_pagination', 5 );
    	}

    – Kyle

    #172094
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Use $prev_post->ID and $next_post->ID has an Id to get the thumbnails.

    -Rui

    #172308
    akimad
    Member
    Post count: 57

    Thank you, it works perfectly 🙂

    #172311
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Thanks Rui

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register