ThemeShaper Forums » Thematic

[closed]

Get-The-Image for Category & Tag Archives

(9 posts)
  • Started 4 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 4 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); ?>
        </div>
    
         <?php the_excerpt(''.__('Read More <span class="meta-nav">&raquo;</span>', 'thematic').'') ?>
    
    </div>

    Hope that helps.

    Posted 4 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:

    <?php
    
        // calling the header.php
        get_header();
    
        // action hook for placing content above #container
        thematic_abovecontainer();
    
    ?>
    
    	<div id="container">
    		<div id="content">
    
                <?php
    
                // displays the page title
                thematic_page_title();
    
                // create the navigation above the content
                thematic_navigation_above();
    
                // action hook for placing content above the category loop
                thematic_above_categoryloop();			
    
                // action hook creating the category loop
                thematic_categoryloop();
    
                // action hook for placing content below the category loop
                thematic_below_categoryloop();			
    
                // create the navigation below the content
                thematic_navigation_below();
    
                ?>
    
    		</div><!-- #content -->
    	</div><!-- #container -->
    
    <?php 
    
        // action hook for placing content below #container
        thematic_belowcontainer();
    
        // calling the standard sidebar
        thematic_sidebar();
    
        // calling footer.php
        get_footer();
    
    ?>

    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 3 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');
    }
    add_action('init','remove_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(); ?>
            </div>
            <?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 {
        padding:0;
    }

    I hope this works for anyone in a similar predicament.

    Posted 3 years ago #
  5. Ridgely,

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

    Cheers,
    Gene

    Posted 3 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 3 years ago #
  7. Bluesky
    Member

    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 3 years ago #
  8. Bluesky
    Member

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

    Cheers,

    Posted 3 years ago #
  9. jhkoning
    Member

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

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.