WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to use TimThumb.php in WordPress 3.0 MU (6 posts)

  1. gbrown88
    Member
    Posted 4 years ago #

    Hey,

    So I am using WordPress 3.0 MU. I am creating theme that has different sections on the homepage for 5 different subdirectory blogs. I am using some code I got here (http://www.staenzwebsolutions.com/get-recent-posts-from-various-blogs-on-wordpress-mu-site/324) to select recent posts by blogid and also selecting by category id. I'll post the code I'm using in a second but heres my problem.

    I want to display a thumbnail image as well and have it resized by timthumb.php. When I just display the image link using get_post_meta it works fine, but when i try to resize it using timthumb, no luck.

    Anyways, heres my code, any help would be great! thanks
    `
    function get_recent_blogposts_featured_nfl($blog_id,$show){
    wp_reset_query();
    switch_to_blog($blog_id);
    global $post;?>
    <?php $my_query = new WP_Query('showposts='.$show.'&order=DSC&category_id=1467');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID; ?>
    <img src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=150&w=350&zc=1" /><h3>" rel="bookmark"><?php the_title(); ?></h3>
    <div style="clear:left;"></div>
    <?php endwhile; ?>
    <?php restore_current_blog();

  2. gbrown88
    Member
    Posted 4 years ago #

    Ok, I'm not 100% sure how to use that code with my code. Here is what I have created, but its still not returning a picture. I think I'm using it wrong. I'm still trying to mess around with it but anymore help would be great. Thanks

    function get_recent_blogposts_featured_nfl($blog_id,$show,$cat_id){
    	wp_reset_query();
    	switch_to_blog($blog_id);
    	global $post;?>
    	<?php $my_query = new WP_Query('showposts='.$show.'&order=DSC&category_id='.$cat_id);
    	while ($my_query->have_posts()) : $my_query->the_post();
    	    $do_not_duplicate = $post->ID;
    		function get_image_path ($post_id = null) {
    		if ($post_id == null) {
    			global $post;
    			$post_id = $post->ID;
    		}
    		$theImageSrc = get_post_meta($post_id, 'thumb', true);
    		global $blog_id;
    		if (isset($blog_id) && $blog_id > 0) {
    			$imageParts = explode('/files/', $theImageSrc);
    			if (isset($imageParts[1])) {
    				$theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
    			}
    		}
    		return $theImageSrc;
    	} ?>
            <img src="<?php echo $theImageSrc; ?>"  /><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
            <div style="clear:left;"></div>
    	<?php endwhile; ?>
    	<?php restore_current_blog();
    }
  3. gbrown88
    Member
    Posted 4 years ago #

    Got it working

  4. corourke
    Member
    Posted 3 years ago #

    Could you perhaps post how you got it working? I'm really frustrated with this issue and would like to resolve it quickly.

  5. sebastianbarria
    Member
    Posted 3 years ago #

    Hey, have you tried to use thumbGen?. Is a plugin that makes exactly the same than timthumb but is so much easier to use and install. Is a plugin made by myself, but please, take a look at it.
    http://www.sebastianbarria.com/thumbgen/

Topic Closed

This topic has been closed to new replies.

About this Topic