0

What I want to achieve

The editor should be able to add galleries via the native wordpress way and choose between 3 different gallery types. These 3 types should all have their custom code-output, defined by me. I'd like to go a step further and give the editor only the gallery-type to choose from.

I imagine the admin-area add-on really simple, like so: enter image description here

Could somebody please walk me through the process of implementing this. Noteform is enough! Specifically:

  1. Giving the editor only a dropdown to choose the gallery-type
  2. Custom output for the different types.

,

Thank you!

0

I will suggest using custom fields for it. List of good ones:

Those custom fields provide you with an option to create a select field and you can display the gallery depending on a type chosen. Please let me know if you need further information.

  • Thanks! and yes, I defenitely need further information. A post will surely have more than one gallery. 1) Are the native wp galleries implemented as a custom post type internally, so that the custom field will be applied to the gallery and not the post in your idea? And 2) How can I hook into the gallery editor to show only this one dropdown menu and hide everything else? – Kater Louis Nov 3 '17 at 18:02
0

I could answer the first question myself. The hook I was looking for is post_gallery (https://codex.wordpress.org/Plugin_API/Filter_Reference/post_gallery) – Whenever a gallery shortcode is getting

To consider when using this hook: The original function generating the html for galleries gallery_shortcode() (in wp-includes/media.php) returns the new content as soon as the filter post_gallery is used somewhere, leaving you alone with quite some work to do if you want to keep the flexibility of the original function. I highly suggest reading the original function first.

As for my second question, I still need assistance– I came up with a rather unsatisfied workaround and now use the columns input in the gallery-settings panel on the right as my gallery_type – Luckily for me the 9 predefined options is exactly the count of types I need.

But for the editor it's quite inconvenient and "hacky" to choose the gallery-type like this..

It's sad, because altering this panel is the only thing left on my wish-list; my post_gallery filter is ready for a shortcode like this [gallery ids='1,4,8' type='7']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.