pageManagement [WP_Admin > Manage > pageMash] Author: Joel Starnes Version: 1.0.2 Author URI: http://joelstarnes.co.uk/ CHANGELOG: Release: Date: Description: 0.1.0 10 Feb 2008 Initial release 0.1.1 12 Feb 2008 Minor fixes > Removed external include 0.1.2 15 Feb 2008 Minor fixes > Fixed CSS&JS headers to only display on pagemash 1.0.0 beta 19 Feb 2008 Major update > Recusive page handles unlimited nested children, collapsable list items, interface makeover... 1.0.1 beta 14 Mar 2008 fixed IE > drag selects text 1.0.2 16 Mar 2008 Major code rewrite for exclude pages FIXME: @fixme with instantUpdateFeature hide will not send the update */ #########CONFIG OPTIONS############################################ $minlevel = 7; /*[deafult=7]*/ /* Minimum user level to access page order */ $excludePagesFeature = true; /*[deafult=true]*/ /* Allows you to set pages not to be listed */ $instantUpdateFeature = false; /*[deafult=false]*/ /* Updates the database instantly after a move using ajax otherwise it will wait for update button press. nb. this feature has not been optimised and enabling will cause much increased server load */ ################################################################### /* INSPIRATIONS/CREDITS: Valerio Proietti - Mootools JS Framework [http://mootools.net/] Stefan Lange-Hegermann - Mootools AJAX timeout class extension [http://www.blackmac.de/archives/44-Mootools-AJAX-timeout.html] vladimir - Mootools Sortables class extension [http://vladimir.akilles.cl/scripts/sortables/] ShiftThis - WP Page Order Plugin [http://www.shiftthis.net/wordpress-order-pages-plugin/] Garrett Murphey - Page Link Manager [http://gmurphey.com/2006/10/05/wordpress-plugin-page-link-manager/] */ /* Copyright 2008 Joel Starnes (email : joel@joelstarnes.co.uk) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ function pageMash_getPages($post_parent){ //this is a recurrsive function which calls itself to produce a nested list of elements //$post_parent should be 0 for root pages, or contain a pageID to return it's sub-pages global $wpdb, $wp_version, $excludePagesFeature, $excludePagesList; if($wp_version >= 2.1){ //get pages from database $pageposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_parent = '$post_parent' ORDER BY menu_order"); }else{ $pageposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' AND post_parent = '$post_parent' ORDER BY menu_order"); } if ($pageposts == true){ //if $pageposts == true then it does have sub-page(s), so list them. echo '
Just drag the pages up or down to change the page order and left or right to change the page's parent, then hit 'update'.
The icon to the left of each page shows if it has child pages, double click anywhere on that item to toggle expand|collapse of it's children.
pageMash works with the wp_list_pages function. The easiest way to use it is to put the pages widget in your sidebar [WP admin page > Presentation > Widgets]. Click the configure button on the widget and ensure that 'sort by' is set to 'page order'. Hey presto, you're done.
You can also use the function anywhere in your theme code. e.g. in your sidebar.php file (but the code in here will not run if you're using any widgets) or your header.php file (somewhere under the body tag, you may want to use the depth=1 parameter to only show top levle pages). The code should look something like the following:
Code:
<?php wp_list_pages('title_li=<h2>Pages</h2>&depth=0'); ?>
You can also hard-code pages to exclude and these will be merged with the pages you set to exclude in your pageMash admin.
The code here is very simple and flexible, for more information look up wp_list_pages() in the Wordpress Codex as it is very well documented and if you have any further questions or feedback I like getting messages, so drop me an email.