View Single Post
Old 02-22-2013, 07:58 AM  
tonyparra
Confirmed User
 
tonyparra's Avatar
 
Industry Role:
Join Date: Jul 2008
Location: In your back seat with duck tape
Posts: 4,568
Wordpress Help: How to convert thumbnail custom field to featured image

I hate when i buy a cool looking wp theme only to find out that the author made it impossible to edit. I recently purchased the cooolzine theme at themeforest and its a great looking theme, however I want to use it on a site that used to use custom fields for the thumbnail, and the theme seems to only work with the featured thumb. Usually when i find an issue like that with a theme i edit it to either use a php statement that uses the featured thumb or a image script like timthumb, or i like to use the get_the_image plugin by justin tadlock. However this theme calls the thumb in a way that i dont understand, so i wonder is there a plugin or script i could run to link images stored on the server in a custom field to the post thumbnail feature. Here a sample of the code if anyone want to take a whack. Also if you can code this reasonably fast hit me up let me know how much and how soon.

Code:
<div class="box article '.$cat[$firstcat]->slug.' '.$tagclass.'">
<div class="text">';

	if (!empty($image)){
	


		$extralen = 0;
		
		$ret .= '
			<div class="thumb">
				<img src="'.$src[0].'" alt="'.$post->post_title.'" title="'.$post->post_title.'" />

				<a href="'.get_permalink($post->ID).'">'.__('read more').'</a>
			</div><!--thumb-->
		';
		
	} // has images


	if ($tlen >= 1 && $tlen <= 20) {
		$headrows = 1;
		$alen = 160 + $extralen;
	}
	
	if ($tlen > 20 && $tlen <= 40) {
		$headrows = 2;
		$alen = 115 + $extralen;
	}
	
	if ($tlen > 40 && $tlen <= 66) {
		$headrows = 3;
		$alen = 100 + $extralen;
	}
	
	if ($tlen > 66 && $tlen <= 88) {
		$headrows = 4;
		$alen = 55 + $extralen;
	}
	
	if ($tlen > 88) {
		$alen = 55 + $extralen;
	}
													
    $pattern = get_shortcode_regex();
	$clean = strip_tags(preg_replace('/'.$pattern.'/s', '$1$6', $post->post_content));
	
	$cut = substr($clean,0,$alen);



$ret .= '<div class="meta"><a class="cat-'.$cat[$firstcat]->slug.'" href="'.get_category_link($cat[$firstcat]->cat_ID).'">'.$cat[$firstcat]-

>name.'</a></div><!--meta-->
	<h2 class="hyphenate"><a href="'.get_permalink($post->ID).'">'.$post->post_title.'</a></h2>
	<a href="'.get_permalink($post->ID).'">
		<span class="hyphenate">
		'.$cut.' &rsaquo;
		</span>
	</a>
</div><!--text-->
__________________

High Performance Vps $10 Linode
Manage your Digital Ocean, Linode, or Favorite Cloud Server. Simple, fast, and secure Server Pilot
tonyparra is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote