Title: rootcase's Replies | WordPress.org

---

# rootcase

  [  ](https://wordpress.org/support/users/rootcase/)

 *   [Profile](https://wordpress.org/support/users/rootcase/)
 *   [Topics Started](https://wordpress.org/support/users/rootcase/topics/)
 *   [Replies Created](https://wordpress.org/support/users/rootcase/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/rootcase/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/rootcase/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/rootcase/engagements/)
 *   [Favorites](https://wordpress.org/support/users/rootcase/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Product Options and Price Calculation Formulas for WooCommerce – Uni CPO] Suboptions images pointing to old url after migration](https://wordpress.org/support/topic/suboptions-images-pointing-to-old-url-after-migration/)
 *  Thread Starter [rootcase](https://wordpress.org/support/users/rootcase/)
 * (@rootcase)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/suboptions-images-pointing-to-old-url-after-migration/#post-13057255)
 * Hi,
 * This solution needs some manual work by replacing the strings in the database.
   
   I’ve placed comments in above code example as hints where to place the function.
   Part of it goes in your theme’s functions.php and the other part goes on any 
   excutable php file, I used the header.php.
 * You need to access the meta_keys _cpo_content from the table postmeta in your
   database. Paste those strings in the header.php part of the code, run the website,
   copy the encoded result back to the database.
 * So be sure to replace the OLDURL, NEWURL and ENCODED_STRING_FROM_CPO_CONTENT 
   in my code example.
 * If you need any more pointers feel free to reply or message me.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Product Options and Price Calculation Formulas for WooCommerce – Uni CPO] Suboptions images pointing to old url after migration](https://wordpress.org/support/topic/suboptions-images-pointing-to-old-url-after-migration/)
 *  Thread Starter [rootcase](https://wordpress.org/support/users/rootcase/)
 * (@rootcase)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/suboptions-images-pointing-to-old-url-after-migration/#post-12407234)
 * For anyone stumbling across this post:
 * The reply to my email stated the official supported way is to go trough all suboptions
   and reselect the image on the new URL. Since this was no option for me I have
   digged further and came up with the following.
 * I found the complete product data stored in the table postmeta with meta_keys
   _cpo_content. These strings are encoded by a uni cpo function.
    That explains
   why the urls remained in the database and weren’t replaced, they were encoded.
 * I have wrote the following for my products, since I had 28 products I replaced
   the encoded strings manually in the database. You could make a function pulling
   all _cpo_content columns, decode, str_replace, encode and update db.
 *     ```
       <?php
       // function in functions.php
   
       function replacer(& $item, $key)
       {
           $item = str_replace(“OLDURL", “NEWURL", $item);
       }
   
       // I placed the following just below the opening body tag
   
       $originalString =‘ENCODED_STRING_FROM_CPO_CONTENT'; //copy from _cpo_content in database
       $decodedString = uni_cpo_decode($originalString);
       array_walk_recursive($decodedString, 'replacer');
       echo uni_cpo_encode($decodedString); //paste back to db. 
       die();
       ?>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)