Last active
May 9, 2018 19:20
-
-
Save robertdevore/128995d5ac92dcc427d561c5e77ae4e1 to your computer and use it in GitHub Desktop.
Create array of all pages in WordPress.
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
| <?php | |
| // Get loop of all Pages. | |
| $args = array( | |
| 'sort_column' => 'post_title', | |
| 'hierarchical' => 1, | |
| 'post_type' => 'page', | |
| 'post_status' => 'publish' | |
| ); | |
| $pages = get_pages( $args ); | |
| // Create data array. | |
| $data = array( 'none' => '' ); | |
| // Loop through pages. | |
| foreach ( $pages as $page ) { | |
| // Add page to $data array. | |
| $data[ $page->ID ] = $page->post_title; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment