• 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. But I would like to have a solution without the use of third party plugins, especially paid ones.

    • This topic was modified 2 years, 12 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 5 replies - 1 through 5 (of 5 total)
  • 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

    (@jonalange)

    @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.

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

    (@jonalange)

    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!

    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.