Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am new to plugin development .I want to get all images of a particular page/post and want to show them as slideshow below the page ..Currently i am able to gather all images in media library and display it...But i want images if that particular page ..I have learnt that to get images of particular template u need to add lines of code in that specific post template ..But how that can be done using a plugin

    $query_images_args = array(
        'post_type' => 'attachment', 'post_mime_type' =>'image', 'post_status' => 'inherit', 'posts_per_page' => -1,
    );

    $query_images = new WP_Query( $query_images_args );
    $images = array();
    foreach ( $query_images->posts as $image) {
        $images[]= wp_get_attachment_url( $image->ID );
    }
foreach($images as $item){

   /// any function not yet decided
}
echo($item);

I m getting image urls in $item ..

share|improve this question
add comment

1 Answer

You would have to put your code in your question into a function. Maybe something like function wpse_91897_get_image() { }. Then try the code below. I haven't tested this but it should work.

function wpse_91897_display($content) {
    global $single;

    $output = wpse_91897_get_image();

    if (is_single()) {
        return $content . $output;
    } else {
        return $content;
    }
}

Then you would add a filter to call the functions for the content.

add_filter('the_content', 'wpse_91897_display');

Then add some CSS to position and style it. It will show up under the content on your post.

share|improve this answer
    
Thanks @pat for your reply..But i m able to get images from post content and also add them my style but the prob is how wud i place in the post content again back to its original postion with my manipulation on images.. –  user1145009 Mar 23 '13 at 6:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.