This is how I'm creating new galleries:

  • I start with making a new post.
  • then I click on Add Media > Create Gallery
  • after that I select a few images from Media Library (let's say 3 of them).
  • and last click on Create a new gallery

After that the contents of my new post look like:

[gallery ids="1,2,3"]

Now I can see a neat beautiful gallery on my post page:

enter image description here

The point is:

  • I don't want this gallery to be shown.
  • I want to get URLs of these images to do something else with them (let's say, a custom slider).

1. Hiding the Gallery.

Additional question, not so important, I need help with 2. mainly

I guess it's quite easy to hide the gallery with CSS (any other ideas, because I don't like this one that much? of course I want the shortcode to still be visible in text editor). In reality I'll be using this on a CPT only so maybe there is some way of disabling galleries for CPT? I want the shortcode to still be in text editor though.

2. Getting the data from Gallery.

Now, there is something really wrong. I've checked it on Twenty Thirtheen and it works, but somehow doesn't with my theme.

$galleries = get_post_galleries_images( $post );

This code displays all the data about above images on Twenty Thirteen but in my theme I'm getting:

array(0) { }

And there's what it's supposed to display (and it does in other themes):

array(1) { [0]=> array(3) { [0]=> string(27) "http://url/to/the/image.jpg" [1]=> string(27) "http://url/to/the/image.jpg" [2]=> string(27) "http://url/to/the/image.jpg" } }

This is how my index.php looks like:

<?php get_header();?> 
    <?php get_template_part( 'loop' ); ?>
<?php get_footer(); ?>


<?php get_header(); ?>
    <?php get_template_part( 'content-single' );  ?>
<?php get_footer(); ?>


   // I've also tried with while (have_posts()) : the_post();
   $galleries = get_post_galleries_images( $post );

I've been trying every possible way and I'm never getting the right results. Any ideas what's wrong?

  • But why do you want to use the gallery images this way to show them in the sliders? why not create a CPT for sliders itself Commented Dec 8, 2013 at 19:39
  • I don't think it's relevant as long as I'm doing something really wrong, but can't really see what, does all gallery functions have to be within a loop? If so, how to create a loop on single page that will work with them, because as you can see from the last snippet the normal way doesn't seem to work. I've been trying all kinds of snippets and functions, from Codex, Otto, other questions, everything seem to be empty. Commented Dec 8, 2013 at 19:40
  • What kind of HTML output are you looking for? Can you give an example?
    – birgire
    Commented Dec 8, 2013 at 20:11
  • Check the edit, third code block for second question. Commented Dec 8, 2013 at 20:15

1 Answer 1


Okay, looks like it was my fault, I've been playing with shortcodes long time ago and I found out something like this within functions.php:

require_once ('gallery-shortcode.php');

Apparently it replaced the original shortcode and when it happens everything gallery-related breaks / returns nothing :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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