Title: Gallery functionality in custom theme
Last modified: March 25, 2022

---

# Gallery functionality in custom theme

 *  [jonalange](https://wordpress.org/support/users/jonalange/)
 * (@jonalange)
 * [4 years ago](https://wordpress.org/support/topic/gallery-functionality-in-custom-theme/)
 * I’m new to creating my own theme and I barely scratched the surface of this topic
   so far. But my end goal would be to create a “gallery like” functionality.
 * Maybe there are some functions or prebuild things in WP that could help me out
   here before I do all of this from scratch.
 * Some terms what I can google for or look in the documentation would help me out
   a lot. Because when I search for stuff on google I only find some basic things
   like finished themes, plugins etc. but no development info (besides the docs).
 * As I said, I would like to have some sort of gallery where the user in the backend
   has a button to add an image (in the best case) a pop up (or other page) will
   open where the user enters some information (image from media uploader, image
   name, tags etc.).
 * The tricky part for me is that I want to have X amount of images possible. So
   when one is added the “add image” button is still there and the user can add 
   as much as he wants.
 * So I don’t define that only (for example) 10 images are possible in 10 hardcoded
   fields.
 * If that pop up thingy is too complicated/ not existing in WP (in an easy way)
   it would be enough to have new fields generated automatically. So the user has
   a button “Add Image” -> On click three fields appear -> The user fills the fields-
   > “Add Image” button again -> Another three fields are generated and the user
   can also fill them.
 * If you need more information, please let me know.
 * I’m glad for any help!
 * On reddit somebody suggested the use of [Advanced Custom Fields](https://www.advancedcustomfields.com/resources/gallery/).
   But I would like to have a solution without the use of third party plugins, especially
   paid ones.
    -  This topic was modified 4 years ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not an Developing with WordPress
      topic

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * (@vijayhardaha)
 * [4 years ago](https://wordpress.org/support/topic/gallery-functionality-in-custom-theme/#post-15495716)
 * Please define 3 things:
 * 1. when you say user, are you talking about admin only or talking about different
   users that will have their own gallery as per user id?
 * 2. Where this gallery(ids of images) are going to be stored? and is it only a
   single gallery or multi gallery thing?
 * 3. When you say `X amount of images` but not hardcoded, how are you going to 
   define that X dynamically? and is it’s same for all users or different for each
   user?
 *  Thread Starter [jonalange](https://wordpress.org/support/users/jonalange/)
 * (@jonalange)
 * [4 years ago](https://wordpress.org/support/topic/gallery-functionality-in-custom-theme/#post-15495765)
 * [@vijayhardaha](https://wordpress.org/support/users/vijayhardaha/) Thanks for
   your reply. I should have done that more clearly.
 * 1. I’m talking about admins in the backend, so not individual users
 * 2. For now only one gallery. Where it’s stored I have no idea right now. I thought
   I will just link images from the Media Uploader to the gallery.
 * 3. Because it’s only for one user it’s the same. But this is the tricky part.
   I don’t want to define X. I just meant that there is no limit of images. Every
   time the admin clicks on “add image” new fields are generated (or something like
   this). Just like for example a to dos list. When you add a to do you have a button
   to add another, and another and so on.
 *  [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * (@vijayhardaha)
 * [4 years ago](https://wordpress.org/support/topic/gallery-functionality-in-custom-theme/#post-15495825)
 * Ok, as it’s only for admin then it should be saved in the options table using`
   update_option`
 * then I am not sure where you’re going to add this button in the backend. and 
   as you’re not looking for a plugin that you will have to custom code for the 
   media uploader. now it depends on your js and basic media uploader knowledge.
 * You’ll find documentation here.
 * [https://rudrastyh.com/wordpress/customizable-media-uploader.html](https://rudrastyh.com/wordpress/customizable-media-uploader.html)
   
   There are two ways, either you can use multiple options to get all the ids each
   time to click the add button, or use single option and append the id in a hidden
   input.
 * For more better understanding, check the WooCommerce plugin code that adds Gallery
   in product page, that will help you a lot.
 *  Thread Starter [jonalange](https://wordpress.org/support/users/jonalange/)
 * (@jonalange)
 * [4 years ago](https://wordpress.org/support/topic/gallery-functionality-in-custom-theme/#post-15495852)
 * Thanks. So far I used the Media Uploader to add single images in a field. For
   example for a logo.
    The only part I don’t know how to do is adding a new “Add
   Image” button dynamically when the first field is “full” and an image already
   selected.
 * But I will check the WooCommerce code. This could actually help me a lot. Good
   idea!
 *  [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * (@vijayhardaha)
 * [4 years ago](https://wordpress.org/support/topic/gallery-functionality-in-custom-theme/#post-15495883)
 * It’s all based on your logic, you can use the same button for adding a new image
   each time and when you choose a select an image in the media uploader then get
   the image id or url whatever is your need, and append it somewhere by logic.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Gallery functionality in custom theme’ is closed to new replies.

## Tags

 * [custom theme](https://wordpress.org/support/topic-tag/custom-theme/)
 * [gallery](https://wordpress.org/support/topic-tag/gallery/)
 * [theme development](https://wordpress.org/support/topic-tag/theme-development/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/gallery-functionality-in-custom-theme/#post-15495883)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
