WordPress.org

Ready to get started?Download WordPress

Forums

Adding default pages to themes (3 posts)

  1. monteburns
    Member
    Posted 5 years ago #

    Hi,
    I'm working on multiple blogs using the Multiblog System: http://wordpress.org/support/topic/162802?replies=9

    What I want to do is to create multiple blogs, but to have pages already created as I create a new blog.

    For example: as I add a new blog, I want pages I've created in the original blog to be present in the new blog. I've scoured the WordPress site and cannot seem to find instructions on this.

    How do I add default pages to a theme?

  2. MichaelH
    Member
    Posted 5 years ago #

    Assuming pages you mean Pages that you write (and are not really part of a Theme), these options are available:

    1. Easiest thing to do is setup your base blog with the Pages and Categories, then use the Tools->Export to create an XML file that you would use on each newly installed blog via the Tools->Import->WordPress option.

    2. Or, could also write the pages and export them out the wp_posts table and then use the SQL import via phpMyAdmin.

    3. And finally, you could control exactly what gets defined as default data during the WordPress installation process by defining a file called install.php in the wp-content folder. In that file put a wp_install_defaults function with something similar to the following: (code example derived from /wp-admin/includes/upgrade.php):

    <?php
    function wp_install_defaults() {
    	global $wpdb;
    
    	// Default category
    	$cat_name = $wpdb->escape(__('Uncategorized'));
    	$cat_slug = sanitize_title(_c('Uncategorized|Default category slug'));
    	$wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')");
    	$wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('1', 'category', '', '0', '1')");
    
    	// First Page
    	$first_post_guid = get_option('home') . '/?page_id=2';
    	$wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(_c('about|Default page slug'))."', '$now', '$now_gmt','$first_post_guid', 'publish', 'page', '', '', '')");
        }
    ?>
  3. bradstinyworld
    Member
    Posted 5 years ago #

    If you want the blogs to have identical pages say for example the same nofollow policy you should write out a page template that only requires you to publish it without adding text.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags