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.

My image galleries are showing only one thumbnail in the post the gallery sits in. http://themeforward.com/demo2/2013/03/08/image-gallery/

My single.php markup can be found here: http://snippi.com/s/akm5jb7

Additionally, previous_image_link and next_image_link are not displaying when the image is clicked (these would lead to the other images in the gallery).

My entire image.php markup can be found here: http://snippi.com/s/ajwa5yh

My gallery shortcode: [gallery link="post" ids="2245,2246,2247"]

share|improve this question
1  
What is the code in setPostViews() function? –  Vinod Dalvi Mar 11 '13 at 4:45
    
Forgive me if I'm completely missing something but these two source codes don't appear to be the same. Are you linking us to the correct file? I lack the rep points to post images so here's a link instead. –  Imperative Ideas Mar 11 '13 at 6:13
    
That is for a post views counter which does not impact this question. –  AndrettiMilas Mar 11 '13 at 6:34
    
Is this with WP3.5? Can you go into the text mode of the post edit screen and paste the gallery shortcode into your question? –  sanchothefat Mar 11 '13 at 12:39
    
Question updated. –  AndrettiMilas Mar 12 '13 at 0:05
show 2 more comments

2 Answers

Try this and verify that the attachments come back correctly when queried directly:

// helper function to return first regex match
function get_match( $regex, $content ) {
    preg_match($regex, $content, $matches);
    return $matches[1];
} 

// Extract the shortcode arguments from the $post
$shortcode_args = shortcode_parse_atts(get_match('/\[gallery\s(.*)\]/isU', $post->post_content));

// get the attachments specified in the "ids" shortcode argument
$attachments = get_posts(
    array(
        'include' => $shortcode_args["ids"], 
        'post_status' => 'inherit', 
        'post_type' => 'attachment', 
        'post_mime_type' => 'image', 
        'order' => 'menu_order ID', 
        'orderby' => 'post__in', //this forces the order to be based on the order of the "include" param
    )
);

echo 'gallery count:' . count( $attachments );

If that count is correct, then the gallery shortcode should be returning correctly. Let me know what that returns.

share|improve this answer
    
Where do I place this? –  AndrettiMilas Mar 12 '13 at 13:54
    
drop that in your page template to see if it spits out the correct count of attachments in the gallery which should be 3 given your example of [gallery link="post" ids="2245,2246,2247"] –  anderly Mar 12 '13 at 13:57
    
It returned "gallery count:1" –  AndrettiMilas Mar 12 '13 at 14:14
    
Ok, in that case, it sounds like there is truly only one attachment. Can you verify whether or not those other attachment ids actually exist under Media? Or if you have access to the db via phpMyAdmin, you could query the post table directly for those IDs. One other way to check for their existence is to see if you can get to these URLs: /wp-admin/post.php?post=2245&action=edit /wp-admin/post.php?post=2246&action=edit /wp-admin/post.php?post=2247&action=edit –  anderly Mar 12 '13 at 19:12
    
Yes, they exist and they are attached to the appropriate post. –  AndrettiMilas Mar 12 '13 at 20:26
show 3 more comments
up vote 0 down vote accepted

It ended up being a problem with a code to pull a custom number of posts via an options panel.

share|improve this answer
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.