Stop WP from creating “Sample Page” and “Hello World!” post

If you’re using Multisite The accepted answer is destructive in that it cancels all other set-up items in the overridden function. A less destructive way to do it for multisite installs is to delete the default content during new blog creation by hooking in to wpmu_new_blog add_action( ‘wpmu_new_blog’, ‘delete_wordpress_defaults’, 100, 1 ); function delete_wordpress_defaults(){ // … Read more

Change page template programmatically ?

It is possible using the template_redirect hook. Looks something like this : function language_redirect() { global $q_config; if( $q_config[‘lang’] == ‘en’ ) { include( get_template_directory() . ‘/page-template_en.php’ ); exit; } else { include( get_template_directory() . ‘/page-template_de.php’ ); exit; } } add_action( ‘template_redirect’, ‘language_redirect’ ); Code is untested, but should look like that. See my similar … Read more

Check if is on child-page of a particular page

You can do that with $post->post_parent. You will have to check if child page’s parent is Services page. So this is how you will check it. I assumed 123 in following code is page ID of your services page. Replace it with actual ID. if ( 123 == $post->post_parent ) { ?> <div class=”col-md-2 col-sm-4″> … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)