Connect with us


Echo Images inside a Post into the Loop



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:

$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..

Continue Reading


  1. Austin

    December 8, 2008 at 3:54 am

    Assuming the image has been added using the WP uploader, here’s a way of doing the same thing using the WP API, which might have a performance advantage:

    <?php $attachments = (array) get_children(array(‘post_parent’ => get_the_ID(), ‘post_type’ => ‘attachment’));
    if ( ! empty( $attachments ) ) :
    $attmt = array_shift($attachments);
    $image_thumb = wp_get_attachment_thumb_url($attmt->ID); ?>
    <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_thumb; ?>” alt=”<?php the_title(); ?>” /></a>
    <?php endif; ?>

  2. frosty

    December 8, 2008 at 10:59 am

    Thanks for that one!

  3. Picsbuzz

    January 7, 2009 at 9:57 pm

    This is great script, it helps me a lots!!! Thank you so much!!
    I wonder if this script can grab the first image in the post which hosted on share host like: flickr or imagesharkus?

    • frosty

      January 7, 2009 at 10:05 pm

      Your welcome, I am not sure. If we could find out details to their database it may be possible.

  4. Nick

    January 15, 2009 at 12:38 pm

    That can be useful

    Nick’s last blog post..Montana Library

  5. Thomas

    August 10, 2009 at 11:00 am

    Hi all,
    First of all, very nice script. I noticed that the output was in html (ie, img src and thumbnailing).
    Does anyone know of any snippet to be able to echo the image via php, without having to name the actual individual image file (eg. tree.jpg), and instead using a variable from a database that names photos in a directory.?

  6. Maor

    September 5, 2009 at 5:33 pm

    Thanks for the tip, liked it!
    .-= Maor´s last blog ..‫וורדפרס 2.8+: איך לא להציג קטגוריות מסוימות בתפריט הצדדי?‬ =-.

You must be logged in to post a comment Login


Looking for the right plugin?



Well, I hope many of you have been using the WordPress plugin directory. It’s a grand location where you can find endless plugin for your WordPress blog.

But sometimes you don’t exactly get what you search for, but according to mdawaffe on WordPress, they have implemented a new open source MySQL text search engine. Well go on, test it out.

Continue Reading


The launch of



Hey, in case you are unaware, WordPress has launched a new site called Check out the full post at the blog. Or visit

… is also now the place to find all that awesome WordCamp footage that was floating around the web without a home. See the presentations you missed and get a peek at behind-the-scenes action. We call it WordCampTV.

You’ll also find slideshows of presentations made by Automattic employees and other WordPress gurus, plus interviews I’ve done with the media and fellow bloggers….

Continue Reading


What is HTTP Protocol?




HTTP stands for Hypertext Transfer Protocol, and it’s the foundation of the web we know today. It’s a set of rules that govern how web servers and browsers communicate with each other to send and receive information.

To understand how HTTP works, let’s consider a simple example. Imagine you want to visit a website, so you type its URL into your browser and hit enter. Your browser sends an HTTP request to the server hosting the website, asking it to send the webpage back to you.

The server receives the request and responds by sending an HTTP response back to your browser. This response includes the HTML, CSS, and JavaScript that make up the webpage, as well as other resources like images and videos. Your browser then uses this information to render the webpage on your screen.

HTTP is a stateless protocol, which means that the server doesn’t store any information about the client’s session. Each request is treated as a separate, standalone event. This is in contrast to protocols like FTP (File Transfer Protocol) or SMTP (Simple Mail Transfer Protocol), which maintain a connection between the client and server for the duration of the session.

One of the key features of HTTP is that it’s based on a request-response model. The client (usually a browser) makes a request, and the server responds with a response. There are several types of HTTP requests that a client can make, including GET, POST, PUT, and DELETE.

GET requests are used to retrieve information from the server. For example, when you visit a webpage, your browser sends a GET request to the server to retrieve the HTML, CSS, and JavaScript that make up the webpage.

POST requests are used to send data to the server, usually as part of a form submission. For example, when you fill out a form on a website and click “submit,” your browser sends a POST request to the server with the form data.

PUT requests are used to update a resource on the server. For example, you might use a PUT request to update the information in a database record.

DELETE requests are used to delete a resource on the server.

HTTP is a crucial part of the internet, and it’s what enables us to access and share information online. Without it, the web as we know it wouldn’t exist.

In addition to the request types mentioned above, there are also several HTTP response codes that a server can send back to the client. These codes indicate the status of the request and whether or not it was successful.

Some common HTTP response codes include:

  • 200 OK: The request was successful and the server was able to fulfill it.
  • 301 Moved Permanently: The requested resource has been moved to a new URL, and the server sends this response code along with the new URL.
  • 404 Not Found: The requested resource could not be found on the server.
  • 500 Internal Server Error: An error occurred on the server while processing the request.

HTTP is an important part of how the web works, and it’s something that most of us use every day without even thinking about it. Whether we’re visiting a website, filling out a form, or uploading a file, we rely on HTTP to send and receive information.

It’s worth noting that HTTP is just one of many protocols that make up the internet. Others include TCP/IP (Transmission Control Protocol/Internet Protocol), which is the underlying protocol that enables the communication between computers on the internet, and SSL/TLS (Secure Sockets Layer/Transport Layer Security), which is used to encrypt communication between a client and server.

Find an overview of HTTP Protocol here. and additional information on HTTP protocol here.

In conclusion, HTTP is a vital part of the internet, and it’s what enables us to access and share information online. Whether we’re browsing the web, filling out a form, or uploading a file, we rely on HTTP to communicate with servers and other clients.

Continue Reading

Random Search Terms


Top Articles

powered by WassUp

Recent Posts: Fully Net Worth . com

Michael Imperioli net worth.

Michael Imperioli net worth.

Michael Imperioli net worth James Michael Imperioli is an actor and TV writer with Italian-American origins. Michael has a net worth close to $25 million. Michael was born in March 1966 in the Mount Vernon area of New York. He grew up in the different areas of New York City, such as New Jersey, Ringwood, […]

Passion Jonesz Net Worth: How Rich is the YouTuber Actually?

Passion Jonesz Net Worth: How Rich is the YouTuber Actually?

Passion Jonesz is an American YouTube star. She is best known for largely focusing on clothes and cosmetics-related content on her channel. As of 2019, Passion Jonesz net worth is estimated to be $400,000. Jonesz was born on March 12, 1992, in the United States. Very limited information is available on her including her early […]

Jadah Blue Net Worth: How Rich is the Black Ink Crew Star?

Jadah Blue Net Worth: How Rich is the Black Ink Crew Star?

Jadah Blue is a reality television personality who is best known for her time on the VH1 reality show called Black Ink Crew which showcases the everyday operations and activities of the staff members at the tattoo shop. She was a part of the crew for season 6 &7. As of 2019, Jadah Blue net […]


%d bloggers like this: