• Resolved wfeu

    (@wfeu)


    Im using the pratt theme with a static front page and static posts page. Right now It does not show any thumbnails unless I add a featured image.

    I have a site with a lot of posts and video posts. My last theme (twentythirteen) would show the first image in the post or the video. It used div entry-content and in content.php for it I found

    <?php if ( has_post_thumbnail() && ! post_password_required() && ! is_attachment() ) : ?>
    		<div class="entry-thumbnail">

    In Pratt Im seeing “entry-summary” and content.php I see

    <?php // Show excerpt for all but single posts (and pages) ?>
    	<div class="entry-summary">
    		<?php the_excerpt(); ?>
    		<hr>
    	</div><!-- .entry-summary -->

    How would I get prat to show first image or embedded video? And what .php files would need to be edited?

    Second: if I click into a single post on pratt I am not seeing previous or next navigation links. How would I add these ? In my old theme these were:

    <nav class="navigation post-navigation" role="navigation">
    		<h1 class="screen-reader-text">Post navigation</h1>
    		<div class="nav-links">

    Thanks for the great themes!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter wfeu

    (@wfeu)

    on the single post navigation (single.php) I added:

    <div class="nav-links-single">
    			<?php
    			echo ' PREVIOUS POST ';
    			previous_post_link();
    			echo ' | NEXT POST ';
    			next_post_link(); ?>
                </div><!-- .nav-links -->

    Thats working now.

    Still trying to figure out post thumbnails for my static blog posts page index.php

    Thread Starter wfeu

    (@wfeu)

    I got the thumbnails (first image or video embed) to show on the blog posts page index.php by changing
    <?php the_excerpt(); ?>
    to
    <?php the_content(); ?>
    in the content.php page

    Im still trying to get the first image or video thumbnails to show on the static main page (template part page-fullpostnoheader.php). I am editing content-page-posts.php and I change

    <div class="entry-summary">
    
    		<?php the_excerpt(); ?>
     	</div><!-- .entry-summary -->

    to

    <div class="entry-summary">
    
    		<?php the_content(); ?>
     	</div><!-- .entry-summary -->

    I get the first image or video as a thumbnail with the full post.

    Is there a way to get thumbnails with the_excerpt ? I want the excerpt with thumbnail on page-fullpostnoheader.php

    Thanks

    Theme Author Tim Nicholson

    (@timnicholson)

    Yes, displaying the_content() instead of the_excerpt() will display whatever is in the post including any images. For the blog index pages where you only want to display the_excerpt you’ll need to find a function somewhere in another theme that retrieves the first image in the post and uses that when a featured image isn’t added. There are many themes that do that, but the reason I don’t is because nowadays people add a lot of “icons” their posts such as social media icons, profile pic thumbnails, even emoticons, etc. It would be hard to determine which is the first “real” image that you would want as a featured image.

    To get you started, you would take something like this from the theme:

    <?php if ( !is_singular() ) : ?>
    		<?php if ( has_post_thumbnail() AND !is_search() ) : ?>
    			<div class="post-thumbnail">
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    
    				<?php the_post_thumbnail( 'post-thumbnail' , $attr = array( 'class'=>'thumbnail img-responsive post-thumbnail' ) ); ?>
    				</a>
    			</div><!-- .post-thumnail -->
    		<?php endif; ?>

    And extent it to something like this. But you’d need to add a function to functions.php called something like get_the_first_image(). In that function you can add the CSS classes “post-thumbnail thumbnail img-responsive” or you could pass those in as arguments like the_post_thumbnail() does. These classes are needed to style the image.

    <?php if ( !is_singular() ) : ?>
    		<?php if ( has_post_thumbnail() AND !is_search() ) : ?>
    			<div class="post-thumbnail">
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    				<?php the_post_thumbnail( 'post-thumbnail' , $attr = array( 'class'=>'thumbnail img-responsive post-thumbnail' ) ); ?>
    				</a>
    			</div><!-- .post-thumnail -->
    		<?php elseif ( get_the_first_image() ) : ?>
    			<div class="post-thumbnail">
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    				<?php echo get_the_first_image(); ?>
    				</a>
    		<?php endif; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Posts Thumbnails "entry-summary" & prev-next on posts’ is closed to new replies.