Increment Page Order As Pages Are Created

The following is a possible solution, but needs some testing to confirm it is viable. It runs only if menu_order == 0 and if it’s not an auto-draft or revision being saved add_action( ‘save_post’, ‘incremental_save_wpse_113767’, 10, 2 ); function incremental_save_wpse_113767( $post_id, $post_object ) { if( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; if( defined( ‘DOING_AJAX’ … Read more

class=”parent” for wp_list_pages?

Phew! Bit more complex than I would’ve liked – if only the filter page_css_class passed back $args it would save a lot of effort (may submit this to trac). Since 3.3 it’s as easy as this! function add_parent_class( $css_class, $page, $depth, $args ) { if ( ! empty( $args[‘has_children’] ) ) $css_class[] = ‘parent’; return … Read more

Dynamic content in a static page

You do want static pages. The easiest way to do this, and a very good way even if perhaps not the only way, is: Create one or more custom template files for your static pages. This is where your PHP comes in. /* Template Name: Calculator */ get_header(); // your calculator code // Whatever PHP … Read more

Get next/previous cousin page

I solved this by getting all pages, assigning them by level, and then getting the next page of the same level. If you also want the previous page then you should probably cache the functionality that groups the pages by level. function wpse16875_next_page_same_level_link() { $next_page_same_level = wpse16875_next_page_same_level(); if ( $next_page_same_level ) { return ‘<a href=”‘ … Read more

Pagination Help on Crazy Custom Authors Page

I doubt you’re going to be able to repurpose WP-PageNavi for this, since you’re not using the built-in queries at all. You should be able to roll pagination yourself, though, and still fall back on some of WordPress’s built-in functionality. In particular, if your URL matches the pattern /meet-the-team/page/3/, the paged querystring variable will automatically … Read more

WordPress admin never finishes saving page on site with large page count

Have you tried optimizing and repairing the table in your MySQL database you are running WordPress on? Your can manually do this with phpmyadmin: http://support.hostgator.com/articles/specialized-help/technical/how-to-optimize-a-mysql-database-using-phpmyadmin Or you can install a WordPress plugin such as WP Database Optimizer and set a regular optimization schedule: http://wordpress.org/extend/plugins/wp-database-optimizer/

Determining Slug Before and After Edit

If the post/page was previously published, and you changed the slug when you edited the page, the old slug gets put into the post meta table with the name _wp_old_slug. So you can use get_post_meta( $post->ID, ‘_wp_old_slug’, $single = false ); to retrieve the former slug(s). I see no reason this wouldn’t work with CPTs, … Read more