Here is a useful trick. Want to call or echo an image into your blog post with our using the custom fields? Well this could be tricky, but I know of a way.
All you have to do is print these lines of code into your
index.php
or home.php
inside the loop:
<?php $id =$post->ID; $the_content =$wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $id"); $home = get_option('home'); $pattern = '!<img.*?src="'.$home.'(.*?)"!'; preg_match_all($pattern, $the_content, $matches); $image_src = $matches['1'][0]; ?>
then after write:
<?php if($image_src != '') { ?> <a href="<?php echo the_permalink() ?>" rel="bookmark" title="Link to <?php the_title(); ?>"><?php the_title(); ?></a><br /> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $image_src; ?>" alt="<?php the_title(); ?>" /></a> <?php } ?>
That’s all! This will look for the first image in your post and echo it in the loop, could be used to show off those pretty thumbnails for the post..
The Ultimate WordPress Real Estate theme with custom developed plugins, single and multiple agents, extensive…
WordPress 2.6.5 is immediately available and fixes one security problem and three bugs. We recommend…
Another plugin I am using on this site: Comment Validation by Jörn Zaefferer. From Jörn's…
Woopra is the world's most comprehensive, information rich, easy to use, real-time Web tracking and…
If you don't know, this site is running the latest WordPress. Which is in Beta…
Celebrity Press is a sexy premium WordPress theme ideal for running a Gossip / Celebrity…