Tuesday, April 28, 2009

WordPress: Disable Canonical URL Redirection Plugin

If you've got WordPress redirecting the browser to a URL, only to cause Apache (or whatever you are running as a web server) to redirect back to the original URL, you've got to disable the canonical URL redirection in WordPress. You can do this by saving the following to a PHP file in the plugins directory and activating it via WordPress.

<?php
/*
Plugin Name: Disable Canonical URL Redirection
Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
Version: 1.0
Author: Mark Jaquith
Author URI: http://markjaquith.com/
*/

remove_filter('template_redirect', 'redirect_canonical');
?>

Changing my WordPress blog domain

The WordPress guys and my co-worker who made some mods on it made it difficult to move our blog from the staging environment to the production environment. As the domain name is different, I had to fix up the post GUID links using string replacement in the PHP file, as I didn't want to change the database on the live site (our PHP files are version controlled, but the data on the DB server is not). I did have to change the URL in the options table in the DB for 2 rows 'cos WordPress would always redirect me to the staging environment's domain name.

After getting the blog all patched up, I finally did a Google search to figure out how other WordPress bloggers moved their blogs, which brought me to this article:
http://codex.wordpress.org/Changing_The_Site_URL

CSS: Center Aligning Text Vertically - Method 3

Another approach to vertically centering text is to change the display property of the container to table-cell and add the vertical-align property with the value middle. This method does not work with MS Internet Explorer.

Example

div#header {
vertical-align: middle;
display: table-cell;
height: 200px;
background-color: yellow;
}

<div>
My text
</div>

CSS: Center Aligning Text Vertically - Method 2

You can center text vertically by using absolute positioning on the child element and setting the top property to 50%. You might have to adjust the margin-top attribute to get the text exactly in the center.

Example

div#header {
position: relative;
height: 200px;
}

div#header span {
position: absolute;
top: 50%;
margin-top: -10px;
}


<div id="header">
<span>My text</span>
</div>

CSS: Center Aligning Text Vertically

The easiest way to center text vertically using CSS is to set the line-height to the same size as the container's height.

Example

//Add this to your STYLE tag or external CSS file
div#header {

height: 100px;
line-height: 100px;
}

<div id="header">
My text
</div>


UPDATE: Also see