Category:WordPress

From MattWiki
Jump to: navigation, search

Fresh Install of WordPress

yum install httpd mysql-server php php-mysql mod_security

We are going to install WordPress the root directory of your website, so this means that your WordPress URL will look something like http://www.example.com opposed to http://www.example.com/wordpress where WordPress is in a folder. So start by change to the web directory and download WordPress.

cd /var/www/
wget http://wordpress.org/latest.tar.gz
chown -R apache:apache html

After you have untared distribution, you will next need to setup WordPress.

  • First screen is the configuration screen

When asked to create a config file, do it.


After you have installed WordPress, go to

Changing Domains

  1. Move all code to the new server. Should be no need to change anything here if your themes, plugins are written properly (IOW, no references to hard-coded domain names)
  2. Move your DB to the new server. There are many ways to do this, but the gist is always to back up the current DB to an .sql file, move that to the new server, then restore using the .sql backup. This can be done via command-line or via GUI. If you are just changing domains and not servers, this is not necessary.
  3. Run the below/attached SQL statement. Change the @orig and @new urls to be the old and new domains you are moving from/to, and that is it. If you have multiple blogs, you will need to run the part of the sql statement that references wp_X_xxxxxxx for as many blogs as you have. See the code comments for more details.
  4. That takes care of everything except the widgets, which are set as serialized data in the DB, and cannot (easily) be changed via an SQL statement. That means that any widgets that might have the old domain hard-coded in the widget settings needs to be changed by hand in the admin widgets area once you have done steps 1,2,3.

Step 3 is the HUGE thing that makes life so much easier once you have that set of SQL statements.

/* usage: use libn; */
use [databasename];
/**********************************************/
/*---DEFINED ORIGINAL ADDDRESS AND NEW ADDRESS FOR FIND AND REPLACE---*/
set @orig = 'www.olddomain.com';

set @new = 'www.newdomain.com';

set @orig2 = concat('http://', @orig);

set @new2 = concat('http://', @new);

/**********************************************/
/*---UPDATE POSTS AND OPTIONS WITH NEW ADDRESS. */
/*---THIS SECTION OF CODE NEEDS TO BE RUN ONCE FOR EVERY BLOG, CHANGING THE*/
/*---TABLE'S NUMBER (wp_x_...) TO MATCH EVERY BLOG NUMBER YOU HAVE*/
UPDATE wp_1_options SET option_value =replace(option_value, @orig2, @new2) WHERE (option_name = 'siteurl' OR option_name = 'home' OR option_name = 'fileupload_url');
UPDATE wp_1_postmeta SET meta_value =replace(meta_value, @orig2, @new2);
UPDATE wp_1_posts SET guid = replace(guid, @orig2,@new2); 
UPDATE wp_1_posts SET post_content=replace(post_content, @orig2, @new2);

/**********************************************/
/*---UPDATE WITH NEW ADDRESS FOR WP CORE TABLES --*/
update wp_blogs SET domain = replace(domain, @orig, @new) ;
update wp_site SET domain = replace(domain, @orig, @new) ;

WordPress Taxonomy

Add the following to your function.php file:

add_action( 'init', 'create_my_taxonomies', 0 );
function create_my_taxonomies() {
        register_taxonomy( 'people', 'post', array( 'hierarchical' => false, 'label' => 'People', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'places', 'post', array( 'hierarchical' => false, 'label' => 'Places', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'events', 'post', array( 'hierarchical' => false, 'label' => 'Events', 'query_var' => true, 'rewrite' => true ) );
}

Taxonomy How-To's

Pages in category "WordPress"

The following 6 pages are in this category, out of 6 total.