ThemeShaper Forums » Thematic


Get-The-Image for Category & Tag Archives

(9 posts)
  • Started 11 years ago by ridgely
  • Latest reply from jhkoning
  • This topic is resolved
  1. Hi, sort of dense with the thematic child theme functions, filters, etc. Especially since I don't want to touch the theme page templates. So Justin Tadlock's Get The Image plugin, which I have installed and activated, requires a call within the loop. So in theory, if I wanted the category archive posts to grab the image and show it, instead of just showing the excerpt, I would have to open up my category.php file and pop
    <?php get_the_image(); ?>
    somewhere inside the category loop. But even if I copied the thematic category.php into my own theme, the file has no place where it would make sense to insert the image script.

    My fledgeling blog is here. I want the "drawings" and "paintings" category archives to show thumbnail images instead of excerpts. I also want archives for certain tags to show thumbnails instead of excerpts. So I am completely stumped: how do I make a function to replace the usual post excerpt with the "get the image" script for these instances?

    Many thanks in advance.

    Posted 11 years ago #
  2. It is actually easier to edit the templates than you'd think, and in this case I would think it easier to do so than filtering the correct function. Just go into the Thematic folder and COPY category.php and tag.php into your child theme's folder. Now you can edit those copies however you wish. And in theory (I haven't used this plugin or tested this), you should just be able to insert your code. I'd probably wrap it in a div so you can style it (if the plugin doesn't automatically do that).

    for instance here is a section from my category.php which is using the template from the Commune Theme. Commune does thumbnails with the timthumb script, but the idea seems the same. I'd guess you could swap out my <?php the image.... ?> w/ yours.

    <div class="entry-content">
        <div class="thumb_150x150">
    	<?php the_image('thumbnail','post-image',true,false,true); ?>
         <?php the_excerpt(''.__('Read More <span class="meta-nav">&raquo;</span>', 'thematic').'') ?>

    Hope that helps.

    Posted 11 years ago #
  3. Thanks! I appreciate the help. Unfortunately, the thematic category.php file is built in such a way that the example you provided above doesn't entirely apply:

        // calling the header.php
        // action hook for placing content above #container
    	<div id="container">
    		<div id="content">
                // displays the page title
                // create the navigation above the content
                // action hook for placing content above the category loop
                // action hook creating the category loop
                // action hook for placing content below the category loop
                // create the navigation below the content
    		</div><!-- #content -->
    	</div><!-- #container -->
        // action hook for placing content below #container
        // calling the standard sidebar
        // calling footer.php

    The action hook thematic_categoryloop refers to a function created in content-extensions.php in the library/extensions folder. So while I'm literate enough to have figured that part out, I'm at the "what now?" stage.

    Posted 11 years ago #
  4. Ok, I got it:

    function remove_category_loop(){ // its an action not a filter so first remove the thematic action
        remove_action('thematic_categoryloop', 'thematic_category_loop');
    function child_category_loop() { // now rebuild your version of the action
     while ( have_posts() ) : the_post()  // Start the loop:
        // This is just what we decided to show in each post ?>
        <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
            <?php thematic_postheader(); ?>
            <?php get_the_image( array( 'custom_key' => array( 'Thumbnail', 'thumbnail' ), 'default_size' => 'thumbnail' ) ); ?>
            <div class="entry-content">
    		<?php thematic_content(); ?>
            <?php thematic_postfooter(); ?>
        </div><!-- .post -->
        <?php endwhile; // loop done, go back up
    add_action('thematic_categoryloop', 'child_category_loop');

    To make the category archive look like a thumbnail gallery, with each thumbnail linked to a post, I hid everything in the post except the thumbnail grabbed by <?php get_the_image( array( 'custom_key' => array( 'Thumbnail', 'thumbnail' ), 'default_size' => 'thumbnail' ) ); ?>.

    The css looks like this:

    .category-drawings .post .entry-title, .category-drawings .post .entry-meta, .category-drawings .post .entry-content, .category-drawings .post .entry-utility {
        display: none;
    .category-paintings .post .entry-title, .category-paintings .post .entry-meta, .category-paintings .post .entry-content, .category-paintings .post .entry-utility {
        display: none;
    .category-artifacts .post .entry-title, .category-artifacts .post .entry-meta, .category-artifacts .post .entry-content, .category-artifacts .post .entry-utility {
        display: none;
    .hentry.category-drawings, .hentry.category-paintings, .hentry.category-artifacts {

    I hope this works for anyone in a similar predicament.

    Posted 11 years ago #
  5. Ridgely,

    Thanks you so much for taking the time to share your solution with us.


    Posted 11 years ago #
  6. You could also go one level deeper and filter the post:

    //Add Thumbnails Using Get the Image
    function childtheme_post_content($title) {
    if (is_category()) {
    	if ( function_exists( 'get_the_image' ) ) {
    		$featuredimg = get_the_image( array( 'custom_key' => array( 'featured_image' ), 'default_size' => 'medium', 'width' => '540', 'height' => '200', 'image_class' => 'feature' ) ); }
    	return $featuredimg . $title;
    } else {
    	return $title;
    add_filter('thematic_post', 'childtheme_post_content');
    Posted 11 years ago #
  7. Bluesky

    I might have found the solution to my problem here...
    But which file do I finally change ?
    tthe functions.php ?
    the content extension.php ?
    or like Helgatheviking, I copy/paste the category.php in my child theme with the new function inside ?

    Posted 11 years ago #
  8. Bluesky

    It works !!! I added it to the functions.php...Now I just need to style it.
    Thank you, this thread was very useful


    Posted 11 years ago #
  9. jhkoning

    Thanks @ridgely - this helped me out too - much appreciated,

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.