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:
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 );
var_dump($galleries);
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(); ?>
single.php:
<?php get_header(); ?>
<?php get_template_part( 'content-single' ); ?>
<?php get_footer(); ?>
content-single.php:
<?php
// I've also tried with while (have_posts()) : the_post();
$galleries = get_post_galleries_images( $post );
var_dump($galleries);
?>
I've been trying every possible way and I'm never getting the right results. Any ideas what's wrong?