• The following request might sound strange, at first. Let me explain…

    I am building a master installation of WordPress that I can just port onto any new site in my newtork of WP sites.

    Now, each site in my network — in addition to sharing the same theme, plugins, and options set up — will also share a number of Pages (such as About, Contact, Sitemap, etc… plus a bunch of others using specific templates). These Pages will appear on each site regardless of other content.

    Here comes my problem and question… At this moment, I can define about 5 such “common” Pages, but this number can change/increase in the future.

    Whenever I will want to add a new “common” Page, I will also need to upgrade each WP installation on every site in my network. In order to make upgrades easier and to possibly allow for automation, it would be important that these “common” pages share the same ID across the entire network.

    But, because I don’t know in advance what and how many of these Pages there will be, I cannot just create them in advance.

    What would be your suggestions?

    As one possible solution, I am considering saving a certain number of empty Pages (say 50, just to be on the safe side), which will be earmarked for “common” pages. The problem with this solution is, however, that I would need to exclude them from any wp_list_pages() one-by-one. Even then, they will clutter the Parent Page drop-down box on Write > Page.

    Any suggestions, comments, or questions will be greatly appreciated.

    Thanks!
    Miroslav

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter miroslav

    (@miroslav)

    Anyone?

    If you can’t be certain ‘in advance’ the number of Pages this will be, I’m not sure what I could recommend for automating their inclusion. However, one option might be to, after your installation script inserts your “common” Pages, have it ratchet up the AUTO_INCREMENT value for the posts table to 51 (or whatever). This at least should protect the IDs for whatever use you want to put them to in the future.

    Thread Starter miroslav

    (@miroslav)

    Thanks, Kaf! The AUTO_INCREMENT idea sounds promising and I can live with a limited number of IDs.

    I understand that it would basically bump up the starting ID number for regular content Pages/Posts to 50 (or whatever I set it to), so that I can use the IDs 1-49 for the “common” Pages.

    Now, I am not familiar with the AUTO_INCREMENT value, at all. So, if you wouldn’t mind telling me how to implement it, I would be grateful.

    Also, how do I then go back to create a Page with ID lower than the value set in AUTO_INCREMENT?

    Thanks!
    Miroslav

    I am not familiar with the AUTO_INCREMENT value, at all.

    It can be set (or rather, reset) through an ALTER TABLE clause:

    ALTER TABLE tablename AUTO_INCREMENT=X

    X being the value to change AUTO_INCREMENT to.

    Also, how do I then go back to create a Page with ID lower than the value set in AUTO_INCREMENT?

    You wouldn’t be able to do it through WordPress, if that’s what you’re asking. You would need to perform an INSERT (through a script or whatnot) to the table that specifies the ID #.

    Thread Starter miroslav

    (@miroslav)

    Kaf, I greatly appreciate your help. Unfortunately, while I understand the concept, the actual implementation is totally foreign to me. Is there any place I could study up on this?

    Ok, consider me confused.

    First, what’s foreign to you? The ALTER clause, the point on forcing the ID in an INSERT, or what?

    Second, you said you’re building a “master installation” of WordPress with several default or “common” Pages as part of it. How are you accomplishing this? I assume through the use of several INSERT queries, most likely added to the upgrade-functions.php script, correct?

    The following is the INSERT syntax from that file for the regular first Page (abbreviated here for sanity’s sake):

    $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, […] VALUES ($user_id, '$now', […]

    You can modify that slightly to set the ID:

    $wpdb->query("INSERT INTO $wpdb->posts (ID, post_author, post_date, […] VALUES (10, $user_id, '$now', […]

    With 10 here (the first ‘VALUE’) being the ID I am inserting as part of my Page record in the posts table.

    Now, if you need SQL help beyond that:

    https://php.about.com/od/learnmysql/Learn_MySQL.htm

    Here’s some basic information on making use of the $wpdb class in WordPress:

    https://codex.www.ads-software.com/Function_Reference/wpdb_Class

    And there are more than a few people who have built custom installation scripts for WordPress and discussed it online somewhere. So a visit to your favorite search engine might lead to some additional insights about your task.

    Thread Starter miroslav

    (@miroslav)

    First, what’s foreign to you? The ALTER clause, the point on forcing the ID in an INSERT, or what?

    Yes, that and a lot more. I have only minimal knowledge of PHP and practically zero MySQL experience. All I know is XHTML and CSS. The rest is beginner knowledge.

    Second, you said you’re building a “master installation”… How are you accomplishing this? I assume through the use of several INSERT queries…?

    No, far from that. Given my limited knowledge, my idea was to do it along the lines of manually importing an existing database and copying an existing WP installation to a new server, as described in this thread.

    The INSERT command is unknown to me, but I can already see the potential. However, it is painfully obvious to me that I won’t be able to do it myself (certainly, not in a reasonable time frame). Do you have any suggestions for who to go to for paid assistance?

    Thanks for your time! ??

    Miroslav, you can join the WP-Pro mailing list, which is intended as a ‘forum’ of sorts to reach those who do WP development (or other type of work) for hire.

    https://codex.www.ads-software.com/Mailing_Lists#Professional

    Thread Starter miroslav

    (@miroslav)

    you can join the WP-Pro mailing list
    I did some time ago, but received zero response. ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Creating Pages with specific ID? Earmarking non-existent Pages for future use…’ is closed to new replies.