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 have several custom post types similar to (place, person,etc.) refer this and under each of these custom post type there are several posts inserted. (ex.http://www.firstpost.com/topic/person/amitabh-bachchan-profile-5605.html)

Each post will be having the image attachments out of which I want to create a gallery page similar to this.

Currently I have progressed to generate a single page for each custom post type. can anyone please advise me for the further process?

EDIT

You can consider the following link: www.newsmirror.agstechnologies.com/topic/place/new-delhi

see the link "View All" on the top right part of the gallery. For the time I have created a normal page and I am passing the ID of the post as the parameter to that page and using that ID I am fetching the attachment images for that post.

but that crates URL something like www.newsmirror.agstechnologies.com/gallery?id=322

but I want the link like: www.newsmirror.agstechnologies.com/topic/place/new-delhi/gallery

can anybody help me on this?

Sorry but I cannot post the direct links so you have to copy paste the URLS.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

If you want to get all images attached to a single post then you can use this

if ( $images = get_posts(array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'numberposts' => -1,
'post_mime_type' => 'image',)))
{
foreach( $images as $image ) {
$attachmenturl=wp_get_attachment_url($image->ID);
$attachmentimage=wp_get_attachment_image_src( $image->ID, full );
$imageDescription = apply_filters( 'the_description' , $image->post_content );
$imageTitle = apply_filters( 'the_title' , $image->post_title );

    if (!empty($imageDescription)) {
    echo '<a href="'.$imageDescription .'"><img src="' . $attachmentimage[0] . '" alt=""     /></a>';
    } else { echo '<img src="' . $attachmentimage[0] . '" alt="" />'; }
    }

} else {
echo "No Image";
}

check also this link http://wordpress.org/support/topic/get-images-attached-to-posts-no-problem-but-need-to-remove-the-featured-image

share|improve this answer
add comment

Try using gallery_shortcode() function, that powers native [gallery] shortcode. It accept plenty of args and generates (semi-)usable resulting markup that can be further customized and/or styled.

share|improve this answer
    
can you please suggest something like creating a virtual page which wraps the gallery of images for post? and create a link through which I will be able to visit the gallery? Preserving the URL is most important for me. –  Rohit Pande Oct 15 '12 at 10:54
    
@Rohit Pande what you want to achieve there sounds like rewrite endpoint (see add_rewrite_endpoint()‌​) but it's not quite my area so not sure. –  Rarst Oct 15 '12 at 18:35
    
Thanks for the reply. Please refer to the details in question again. I have edited it and provided the exact scenario. Please see if u can help me out. –  Rohit Pande Oct 16 '12 at 9: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.