WordPress.org

Ready to get started?Download WordPress

Forums

Change URL's when uploading to server? (3 posts)

  1. Arterus
    Member
    Posted 1 year ago #

    I do apologise folks, I'm sure this question has been asked a thousand times, but its hard to find a specific answer (I can find lots of URL posts, but none answering this specific question)

    I am creating a website on my localhost. So every picture, post, blog etc has a 'localhost' URL address.

    When I'm done with my website, and want to put it on my web server... Do I have to go though the ENTIRE site and change all those links manually?

    Surely there has to be another way? I'm sure I'm missing something.

    Thanks in advance for your help.

  2. s_ha_dum
    Member
    Posted 1 year ago #

  3. zex2911
    Member
    Posted 1 year ago #

    you can check out this article, but for the future reference just a small hint. add this to your functions.php

    // create shortcode for website's home page adress
    function myUrl($atts, $content = null) {
    	extract(shortcode_atts(array(
    		"href" => get_option('home')
    	), $atts));
    	return $href;
    }
    add_shortcode("url", "myUrl");

    Than, when you need to hard-code something you can use

    <a href="[url]/whatever...">

    or with the images that link to your localhost, just change that

    <img src="http://localhost/wp-content/...">

    to

    <img src="[url]/wp-content/...">

    There is probably better way to do that, but this was easiest thing for me. That way you can change your site url without being afraid of hard-coded links

Topic Closed

This topic has been closed to new replies.

About this Topic