How to configure WordPress to handle 75,000 pages?

The problem comes from the fact that, in order to display pages and their hierarchy, WP has to load all of them and then build the tree in memory. So, you are saved if you can convert most of those pages into one or several non-hierarchical custom post types. The permalink structure can be emulated.

How to check if I’m on the last page of posts?

The WP_Query object contains a max_num_pages field which contains how many pages of posts there are. You can compare the current page number with it. (This is how get_next_posts_link() does it.) global $wp_query; $current_page = $wp_query->get( ‘paged’ ); if ( ! $current_page ) { $current_page = 1; } if ( $current_page == $wp_query->max_num_pages ) { … Read more

How to load javascript on custom page template?

You can use is_page_template to check if you template is being used and load your scripts based on that ex: Add this code to your functions.php: add_action(‘wp_enqueue_scripts’,’Load_Template_Scripts_wpa83855′); function Load_Template_Scripts_wpa83855(){ if ( is_page_template(‘custom-page.php’) ) { wp_enqueue_script(‘my-script’, ‘path/to/script.js’); } }

How can I keep the content of my pages version controlled?

You already got something like this built in: Revisions. // Define the nr of saved revisions in your wp-config.php define( ‘WP_POST_REVISIONS’, 30 ); You can simply grab them by calling get_posts() with a post_type of revision. To show the difference between two revisions simply use wp_text_diff(). // Example $revisions = get_posts( array( ‘post_type’ => ‘revision’ … Read more

Custom Post Type Slug / Page Slug Conflict – Prevent use of reserved slug on page save?

The following 2 filters allow you to hook into when WordPress checks the slug and are found in the function wp_unique_post_slug() in the wp-includes/post.php file. There are 2 filters, one for hierarchical posts and one for non-hierarchical. The hierarchical filter provides the ID for the post parent so if the $post_parent is 0, you know … Read more