0

I would like to add a container around the default [gallery] output. I don't want to modify any core files, and add unusual lines to my functions.php. How to do that? What's the most elegant method?

1

Well, since you don't want to edit core files (which is absolutely fine, and unnecessary) and also don't want to do it by means of PHP (meaning functions.php, for instance), here's a jQuery approach:

$('div[id^="galleryid-"]').wrap('<div id="SOME_ID" class="SOME_CLASS" />');

BTW, you know there already is a container div that you can hijack for CSS purposes, right?

  • yes, there is a div with gallery class, but I need one more for a slider plugin. Is it the only solution? Dont you have a small code like this but with php? – Rolnin Apr 4 '13 at 12:49
  • No, I'm afraid there is no short PHP solution. If you want to use the post_gallery filter, for instance, the code would be much longer. But why don't use the jQuery function? Do you have difficulties using/implementing it? Do you have anything against jQuery per se? – tfrommen Apr 4 '13 at 12:53
  • No, I can implement it. I don't like to use javascript to modify the structure. But I need to use it, because I don't want to use long php code for that. Thank you! – Rolnin Apr 4 '13 at 13:07

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.