Support » Plugin: Easy Image Gallery » Custom Site – Only Most Recent Gallery Showing

  • Resolved abstractpurity


    I have just installed the Easy Image Gallery and I am trying to get it running on a custom site I have developed with wordpress integration.

    I have two problems:

    1) If I have a gallery in more than one post, only the most recent gallery is shown in all posts. I am calling the content of each post with:

    $WPPosts = get_posts($WPConditions);
    foreach ($WPPosts as $WPPost) : start_wp();
    echo do_shortcode($WPPost->post_content);

    2) The jquery doesn’t seem to be activating for the prettyphoto element – what should I add into my $(document).ready( function(){ to activate the elements? (note I have manually included the jquery.prettyPhoto.js file from your lib directory)

    you can see examples of both these errors at

    Please help as I would like to integrate this gallery into more than one website!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,

    I can’t support custom modifications as this plugin was only designed to be used on single posts/pages, but have a look at the JS that is outputted onto the page when used as intended. You’ll need to load this also in addition to the scripts. The JS can also be found in the easy_image_gallery_js() function in includes/scripts.php.

    ok that’s helpful in regards to the js stuff, but i’m still left a bit lost as to why it is only displaying the msot recent gallery – can any of your functions be run while inputting the Post ID to make sure the correct gallery is pulled out?

    It’s likely that it’s only showing the first gallery because yes, you need to pass along the ID of the post you’d like to show the gallery for. Sounds like WordPress is using the first one it can find in the query.

    Unfortunately, there’s no function that can take the post’s ID as a parameter, but it’s something I have considered and I may add it in a future update.

    could you point me in the right direction to add it into the code myself for my own use? ie where abouts I can find the command which actually finds and displays the gallery

    The function that outputs the gallery is easy_image_gallery() in includes/template-functions.php

    cheers – i’m looking at it now. I might be doing a bit of a hatchet job on it, but i’ll throw back my results to you if there’s any reusable code you can use 🙂

    OK, I have figured that the get_posts command when looped as follows doesn’t update the global $post variable – unless I do it explicitly on each iteration. This is allowing for multiple galleries to appear without changing your code.

    Where it gets more hairy is that there is no way to differentiate between the different galleries so that they appear in separate prettyphoto boxes rather than all as one big gallery.

    Hatchet job begins!

    $WPPosts = get_posts($WPConditions);
    foreach ($WPPosts as $WPPost) : start_wp();
    $post = $WPPost;

    DONE!! 😀

    Ok, I changed one line in your code to get it detecting the current post ID and allowing for multiple galleries on the one page

    I changed line 332 of template-functions.php from:

    $rel = easy_image_gallery_count_images() > 1 ? ‘rel=”‘. $lightbox .'[group]”‘ : ‘rel=”‘. $lightbox .'”‘;


    $rel = easy_image_gallery_count_images() > 1 ? ‘rel=”‘. $lightbox .'[‘.$post->ID.’]”‘ : ‘rel=”‘. $lightbox .'”‘;


    Glad you were able to put something together!

    You may want to consider writing your own function if you haven’t done so already from a separate plugin or from your child theme, so when I update you won’t lose your custom modifications.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom Site – Only Most Recent Gallery Showing’ is closed to new replies.