WordPress relative links for regular non image links

There’s a couple of things that you might be able to do here depending on how you are creating your links. Are you talking about page content or are you working in the theme template.

If in the theme template you can do use the <?php bloginfo('url'); ?> to get the base path of the blog. That will change from server to server.

If in the page content you can start your link with the backslash / character before the relative link. That should keep your links relative to the server.

Does that help?

Another option would be to run a replace function on all links in the database after you’ve migrated the site over to the new server. It’s a very easy script to run from PHP MY ADMIN.

Something like this:

UPDATE wp_posts SET post_content = REPLACE(post_content, 'staging.server.com', 'www.productionserver.com');

(credit to Barry Wise)