ThemeShaper Forums » Thematic

[closed]

creating a thumbnail gallery in a category archive

(2 posts)
  • Started 4 years ago by psflannery
  • Latest reply from mgwaters
  • This topic is not a support question
  1. This took me a little while to figure out, but I finally cracked it so in the spirit of these forums I thought I would post my solution in the hope it helps someone trying to do something similar. So, for anyone working on a portfolio style theme and wanting to create a thumbnail gallery of their work in the category archives that doesn’t display any text associated with the post, here goes -

    First add thumbnail support, I am specifying a custom size to display in the chosen category, chose whatever suits you and don’t forget to download and run the regenerate thumbs plugin for these to take effect:

    //Add Post Thumbnails Support
    if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 150, 150, true ); // Default thumbnail size
    	add_image_size( 'category-thumbnail', 300, 300 ); // Category thumbnail size
    }

    Second, create a custom post title that includes the thumbnail for your chosen category:

    //Put the thumbnail in the post title
    function childtheme_post_title($title) {
       if (is_category('drawing')) { ?>
       <a href="<?php the_permalink() ?>" rel="bookmark" class="entry-thumb"><?php the_post_thumbnail('category-thumbnail'); ?></a>
    	   <?php
    } else {
    return $title;
    }
    }
    add_filter('thematic_postheader', 'childtheme_post_title');

    Lastly, create a custom category loop for the chosen category that only displays the thematic_postheader:

    //Creating the content for the Category
    function remove_category_loop() {
      remove_action('thematic_categoryloop', 'thematic_category_loop');
    }
    add_action('init', 'remove_category_loop');
    
    function childtheme_category_loop() {
    if (is_category('drawing')) {
      while ( have_posts() ) : the_post();
            thematic_abovepost(); ?>
    	<div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    		<div class="entry-content">
    		<?php thematic_postheader() ?>
    	        </div>
    	</div><!-- .post -->
           <?php
             thematic_belowpost();
      endwhile;
    } else {
           while (have_posts()) : the_post();
           thematic_abovepost(); ?>
           <div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class(); ?>">
           <?php thematic_postheader(); ?>
                 <div class="entry-content">
           <?php thematic_content(); ?>
                 </div><!-- .entry-content -->
           <?php thematic_postfooter(); ?>
           </div><!-- #post -->
        <?php
     thematic_belowpost();
     endwhile;
     }
    } // end category_loop
    
    add_action('thematic_categoryloop', 'childtheme_category_loop');

    These are the basic steps and can be modified and styled to your choosing. Hope it helps someone.

    Posted 4 years ago #
  2. Hello, I am trying to do a similar effect for one category, and have a grid style (3 images/tn wide) by 2~4 rows (haven't decided yet on how many rows) So you identified the category by including this correct >> if (is_category('drawing'))

    I re-defined by medium sized thumbnails to be resized to 250px wide in the admin > setttings > media section so I should just be able to grab those correct? So I wouldn't need your first function? Also, I'd love to include the post title and excerpt. Did you just eliminate those using css styles?

    Did you have to create a custom template?

    Any assistance is appreciated!

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.