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..
When it comes to your business, marketing is extremely important. With the popularity of social…
Maybe you have the new software on your Apple device that has made headlines as…
Knowing Where To Start There are a number of conceptual business models that are used…
Google recently announced it has launched its Disavow Tool which allows webmasters to alert Google…
Depending on your needs, WordPress plugins are the best and worst aspects of WordPress. The…
Classic CTR Themes For WordPress have made it pretty easy to build informational websites using…