• Resolved jwvantilburg

    (@jwvantilburg)


    Hi Andy / Drivingralle,

    Saw the plugin, great idea. I know some css and PHP but not the whole riddle.

    Just curious where I need to implement this in the edito. I am using wordpress 4.1 with the Bridge theme. I only want to display the galleries in the single posts and the blogrol as featured images. So I guess I have to implement in in single.php and blog-large-image.php (the one I’m using).

    Is it simply inserting this code

    $galleryArray = get_post_gallery_ids($post->ID);

    <?php foreach ($galleryArray as $id) {

    <img src=”<?php echo wp_get_attachment_url( $id ); ?>”>

    <?php } ?>

    In to these templates?

    Hope you can help me with this, would be great. Not sure what you meant with
    this ‘Do you know how to get anchor links from inside the loop?’ in another post though.. (I’m dutch:) )

    Well thanks in advance and for creating the plugin. Hope it’ll work for me too.

    Best,

    JW

    https://www.ads-software.com/plugins/featured-galleries/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Andy Mercer

    (@kelderic)

    Basically there are two parts to creating something like this. There has to be code to create the interface in the admin section that lets a user add images to create the gallery and store the data in the WordPress database. The second is code in the theme itself that retrieves the data from the database and converts it into an actual image gallery on the webpage.

    This plugin does step 1. Step 2 I’ve left to theme developers, because it means that they can be flexible. Data is stored as single text entry, with the image IDs separated by commas. You need to add code in the theme template file to retrieve this data, then split it into an array, and then loop through the array. Inside this array loop, you have to convert the image ID into the URL of the image, and create the HTML.

    The example code that you listed in your question retrieves the data using a custom function which I’ve built in, that does the conversion from comma-delimited string to array for you. It gets the array, then it loops through using the foreach. It gets each image’s URL using the WordPress function wp_get_attachment_url(); This code will end up giving you a list of images.

    If you place that on single.php, it’ll be the full gallery. You can tweak it to get just the first image of the gallery for the homepage. You can do this by using this code get_post_gallery_ids($post->ID,1);. The 1 will tell it to just grab a single item. It’ll still be an array though, so still do the for loop.

    Given the large number of people wanting pre-built galleries, I’m considering writing a few examples and including them. If the plugin had something like that included, would it be helpful to you?

    Plugin Author Andy Mercer

    (@kelderic)

    Since you haven’t responded I’m going to mark this as resolved. If you still have questions, add a comment here and change the status back to un-resolved.

    DrPaul

    (@paul6161719)

    Given the large number of people wanting pre-built galleries, I’m considering writing a few examples and including them. If the plugin had something like that included, would it be helpful to you?

    Andy, For Step 2 that you mention, I’ve tried placing the above code in my child theme CSS, but with no luck. Would you be kind enough to post the code that I need to place and where. (Sorry, my CSS skills are not the best. Don’t feel you are insulting me by using a paint-by-numbers approach!)

    Thanks!
    Paul

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Featured Galleries implementation’ is closed to new replies.