Last active
August 29, 2015 14:00
-
-
Save michaelbrazell/11264754 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* A dashboard widget that lists out pages in a heirarchy | |
* Add this to the end of your "Functions.php" file in your theme directory | |
* | |
* This function is hooked into the 'wp_dashboard_setup' action below. | |
*/ | |
function site_map_edit() { | |
wp_add_dashboard_widget( | |
'site_map_edit', // Widget slug. | |
'List Pages by Site Map', // Title. | |
'site_map_edit_function' // Display function. | |
); | |
} | |
add_action( 'wp_dashboard_setup', 'site_map_edit' ); | |
/** | |
* Create the function to output the contents of our Dashboard Widget. | |
*/ | |
function site_map_edit_function() { | |
// Code uses list_pages with $args | |
$args = array( | |
'sort_order' => 'ASC', | |
'sort_column' => 'post_title', | |
'hierarchical' => 1, | |
'child_of' => 0, | |
'parent' => -1, | |
'offset' => 0, | |
'post_type' => 'page', | |
'post_status' => 'publish' | |
); | |
?> | |
<h2>Pages List</h2> | |
<ul> | |
<?php | |
$pages = get_pages(); | |
foreach ( $pages as $page ) { | |
$output = '<li><a href="/wp-admin/post.php?post=' . $page->ID . '&action=edit">'; | |
$output .= $page->post_title; | |
$output .= '</li>'; | |
echo $output; | |
} | |
?> | |
</ul> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment