WordPress.org

Ready to get started?Download WordPress

Forums

Easy Image Gallery
[resolved] Custom Site - Only Most Recent Gallery Showing (10 posts)

  1. abstractpurity
    Member
    Posted 6 months ago #

    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);
    endforeach;

    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 http://www.abstractpurity.com/photography.php

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

    http://wordpress.org/plugins/easy-image-gallery/

  2. sumobi
    Member
    Plugin Author

    Posted 6 months ago #

    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.

  3. abstractpurity
    Member
    Posted 6 months ago #

    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?

  4. sumobi
    Member
    Plugin Author

    Posted 6 months ago #

    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.

  5. abstractpurity
    Member
    Posted 6 months ago #

    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

  6. sumobi
    Member
    Plugin Author

    Posted 6 months ago #

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

  7. abstractpurity
    Member
    Posted 6 months ago #

    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 :-)

  8. abstractpurity
    Member
    Posted 6 months ago #

    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;
    endforeach;

  9. abstractpurity
    Member
    Posted 6 months ago #

    DONE!! :D

    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 .'"';

    to:

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

    Result!!!

  10. sumobi
    Member
    Plugin Author

    Posted 6 months ago #

    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.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.