Get all images from single post in WordPress

by Bhumi // Nov 25,2012 // 3 comments

Get all image from single post

WordPress is turning into a platform for developing web applications so almost every kind of site you can develop using wordpress and to work with wordpress is pretty easy than the other applications.

Recently,I wanted to develop one slider which display all images from single post and images are slide into the slider.

As usual, I have used most common function of wordpress is get_posts function to fetch images from the post and for that i have used ‘post_type’ is equal to attachment.

Now, let’s lay down the WordPress code that does this:

This will load all images attached to the post into the $attachments variable then you can use a foreach loop on them to get your images display.

Above code display all the images from single post and you can use those images for slider or anything else you want to use. ;).

That’s it.I hope this article give you a good idea of how to get all images of single post/page.

Thanks for reading and feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.


To Create custom field in Woocommerce Products Admin Panel

WooCommerce is the most Widely used and well known e-commerce plugin for WordPress.WooCommerce creates the products custom post type and sometimes you want own custom READ MORE

category description with HTML editor in WordPress

Today I am going to explain how to add WYSIWYG editor to category description. Sometimes you want detailed HTML text as description in category page READ MORE

Hook to change post URL with external one in WordPress

After a long i get time to post because of very busy schedule.Today I arranged sometime and come with something new. In this article, I READ MORE

To create extra field into category or Custom Taxonomy in WordPress

Today I am going to explain about to create extra field into category section or custom Taxonomy in WordPress. Sometimes in wordpress, we need some READ MORE

Parsing a RSS Feed with WordPress

Nowadays,RSS Feed are commonly used in all sites which provides you the latest news or information of site. You must have to be take care READ MORE

Feedback 3

  1. An outstanding share! I’ve just forwarded this onto a coworker who was doing a little research
    on this. And he actually ordered me lunch simply because I found it for him…

    lol. So let me reword this…. Thank YOU for the meal!!
    But yeah, thanks for spending time to discuss this topic
    here on your web page.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">