首页 > Wordpress开发 > Ripping out the “wp-” Prefix

Ripping out the “wp-” Prefix

2007年4月8日

今天费尽心思修改wp的前缀,一直没有找到解决的方案,于是用E文Google了一下,果然不同凡响,看来E文不能丢啊。。。

One of the more annoying aspects of WordPress is the fact that most of the files and the complete database is prefixed with “wp-” in the case of the database this is “wp_”. In this, the first phase of customizing WordPress we will address this by cleaning up the project and removing all of those prefixes.

Below are the exact steps necessary if you wish to do this yourself (Recommended for existing installations) alternatively you can go straight to the end and download the zip file for a cleaned version.

1、Delete the readme.html file as this contains information relating to upgrading WordPress. See “Customizing WordPress Introduction” for more information.
2、Open all of the project files in your favourite PHP editor, I used an editor called ConTEXT for this task. Dreamweaver is also very good for string replacements. Using a string replace function replace all instances of “wp-” with nothing, thus removing the prefix. When complete save and close all files.
3、Browse through the structure of the project and rename each of the files which have the “wp-” prefix.
4、Rename and remove the “wp-” prefix from the three directories: wp-admin, wp-content, wp-includes.
5、Rename the file “config-sample.php” to “config.php”. Open this file in your editor and browse to line 9.

Replace: $table_prefix = ‘wp_’;
With: $table_prefix=”;

6、Open the file “includes/functions.php” and browse to line 2183.

Replace: $>main($query_vars);
With: $wp->main($query_vars);

7、Open the file “includes/templates-functions-category.php”and browse to line 321.

Insert: if (is_array($categories)) {
Above: foreach ( $categories as $category ) {

Browse on to line 387.

Change: } to }}

That’s all there is to it!

Wordpress开发

  1. w
    2007年4月18日14:14 | #1

    最近 ,怎么不更新了?饭哥。

  2. 2007年4月18日17:28 | #2

    呵呵,最近忙啊,一直没时间写东西。。。

  3. jeepmac
    2010年3月16日09:15 | #3

    Would you please post the original web site of your reference?

  4. 2010年3月17日21:41 | #4

    Sorry I couldn’t, for this was referenced nearly 3 years ago n I forgot the source. Are you the author of this article? I would like to post the reference if you could tell me where the source is. :smile:

  1. 2010年3月16日11:20 | #1