• Resolved machination

    (@machination)


    Hello,

    I’ve been trying various plugins that enable thumbnails for excerpts and other uses of the thumbnail-from-posts / featured image functionality.

    However, I can’t seem to get the thumbnails to show up anywhere.

    I’m currently trying out the Filterable Portfolio and followed all the instructions: https://www.wearepixel8.com/blog/filterable-portfolio/

    I put this in my functions.php:
    add_theme_support( ‘post-thumbnails’ );
    set_post_thumbnail_size( 150, 150, true );
    and it lets me upload thumbnails via the individual post pages. I can see the newly-uploaded thumbnail.

    But I created my own theme, so I’m wondering if I have to enable something somewhere else or if I’m missing something when it comes to activating the “Featured Image”.

    Any help or guidance would be really appreciated!

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try this code in your functions.php, this works if you have a featured image uploaded to your post and you want it to show up if you’re using excerpts. You can change the size of the thumbnail in the array

    function my_excerpts($content = false) {
            // If is the home page, category, an archive, or search results
    	if(is_front_page() || is_home() || is_category() || is_archive() || is_search()) :
    		global $post;
    		$content = $post->post_excerpt;
    
    	// If an excerpt is set in the Optional Excerpt box
    
    		if($content) :
    
     the_post_thumbnail(array(200,160), array('class' => 'alignleft excerpt-thumbnail'));
    			$content = apply_filters('the_excerpt', $content);
    
    	// If no excerpt is set
    		else :
    			$content = $post->post_content;
    			$excerpt_length = 55;
    			$words = explode(' ', $content, $excerpt_length + 1);
    			if(count($words) > $excerpt_length) :
    				array_pop($words);
    				array_push($words, '...');
    				$content = implode(' ', $words);
    			endif;
    			$content = '' . $content . '
    
    ';
    
    		endif;
    	endif;
    
    // Make sure to return the content
    	return $content;
    
    }
    
    add_filter('the_content', 'my_excerpts');
    Thread Starter machination

    (@machination)

    Doesn’t seem to be working properly.

    Here’s the functions.php file: https://pastebin.com/Ecye08mG

    Thread Starter machination

    (@machination)

    OK, I re-did the post and it seems to be working now without any further code. Thanks for the help though!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Enabling thumbnails from posts’ is closed to new replies.