WordPress.org

Ready to get started?Download WordPress

Forums

Does Anyone have a solution to stop widgets disappearing when you change URL (3 posts)

  1. phillbooth
    Member
    Posted 2 years ago #

    Making a new wordpress site! Great :-)

    Only trouble is there is already a website there with visitors going to it, so we have two options, make the website on a new server so the URL while we set it up will me http://12.34.36.78/mywebsite.com or set it up in a sub folder http://www.mywebsite.com/newdesign etc.

    Everything works great, but with some widgets (and sometimes template options as well) they just disappears from the website when the url is changed to the live site (http://www.mywebsite.com).

    This problem has been bugging me for months, the only solution I have found is a 3 step process that includes patching the wp-core includes/functions file (something I dont want to do as it prevents upgrades).

    I understand that the problem lies in how the wp widgets and templates are stored in the wp options db table but before I start a new build I would really like to hear peoples work-arounds to this?

    Thanks

  2. karenalma
    Happiness Engineer
    Posted 2 years ago #

    If I understand your issue correctly, I've had this problem as well. My current method is to use my hosts file on my computer. So, I can type in http://mysite.com and see the site online.

    Causes a bit of a problem when I have to help a client view the site, but so far they are fine with me editing their host file. Typically they think it's cool that although the site is "live" no one can see it.

    I just ran across this though:
    http://www.velvetblues.com/web-development-blog/wordpress-plugin-update-urls/

    I've never used it, but it looks promising.

  3. phillbooth
    Member
    Posted 2 years ago #

    Wow that seems a lot more simpler, I will test it later today and let me you know how I get on.

    Before I was using a file to find/replace URL's in the database http://davidcoveney.com/782/mysql-database-search-replace-with-serialized-php/

    then a serialization fixer to correct the options file
    http://davidcoveney.com/575/php-serialization-fix-for-wordpress-migrations/

    and finaly editing the maybe_unserialize function in the wp-includes/functions.php file to the below so the changes I make above stay

    function maybe_unserialize( $original ) {
        if ( is_serialized( $original ) ) {
            $fixed = preg_replace_callback(
                '!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|i:|o:|N;))!s',
                'serialize_fix_callback',
                $original );
            return @unserialize( $fixed );
        }
        return $original;
    }
    function serialize_fix_callback($match) { return 's:' . strlen($match[2]); }

    But of course this could be removed if i update wordpress

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.