Last active
September 19, 2017 19:19
-
-
Save keeneyemedia/ad11b4b7e2592cd7cf6d to your computer and use it in GitHub Desktop.
[ACF Random Gallery Post - Step 1] #tutorials #acf_random_gallery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create a new WP_query to get all the posts from the 'gallery' custom post type | |
$args = array( 'post_type' => 'gallery', 'posts_per_page' => -1 ); | |
$posts_query = new WP_Query($args); | |
// Setup the variable to hold the array for ALL IDs of all galleries | |
$galleries = array(); | |
// Using our new WP_query, loop through galleries, and add each ID to the $galleries array | |
while ($posts_query->have_posts()) { | |
$posts_query->the_post(); | |
$galleries[] = strval( get_the_ID() ); | |
} | |
// Do a final reset so we can continue below | |
wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment