Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

CHAPTER 1 • The Anatomy of a WordPress Install 11


It is empty here, which means that it will pass the character set in DB_CHARSET as the
collation. By default, that is UTF-8, but if you need this to be something specific, you can add
it like this:


define('DB_COLLATE', 'character_set_of_choice');


USEFUL WP-CONFIG.PHP FEATURES


The previous changes and settings might be the most commonly used parts of wp-config.php,
but there are other things you can do. Beginners beware here because wp-config.php is no
playground. If you fiddle too much with this file and make a mistake somewhere, you can take
down your entire site. If you do intend to play with wp-config.php, do it in a test install until
you know for sure what you’re doing.


With that said, there are some useful things you can do with wp-config.php. One of these is
overriding the site URL and WordPress path usually set in the database (in the wp_options
table) using the General Settings page. You can use WP_SITEURL to set the site’s URL directly
in wp-config.php if you like:


define('WP_SITEURL', 'http://mydomain.com/blog/');


Likewise, if you want to define the path to the WordPress install, you can do that directly in
wp-config.php as well, using WP_HOME:


define('WP_HOME', 'http://mydomain.com/wp/');


Both these techniques will override the settings within the WordPress admin interface, as will
WP_CONTENT_URL. As the name hints, this will define where the wp-content folder is
located, making it possible to move it someplace else:


define('WP_CONTENT_URL', 'http://mydomain.com/files/wp-content');


Notice the lack of the trailing slash in the path to the wp-content folder. There are similar
possibilities for the plugin directory; you’ll soon note that most of these path settings work
the same way. Naturally, you can use PHP or the server settings themselves to point these to
the correct place dynamically, but I’ll not delve further into that.


Post revisions are saved versions of posts and pages. You can disable them if you like:


define('WP_POST_REVISIONS', false );


Should you want to keep them around but just save up to five revisions, for example, you just
change false to a number:


define('WP_POST_REVISIONS', 5 );

Free download pdf