After database migration, theme mods don't show

My Wordpress installation has only one theme which is active. The wp_option entry for it shows there are 31 theme mod entries.

a:31:{s:18:custom_css_post_id;i:5248;s:30:theme_settings_api_keys_google;s:39:xxx.....etc..;s:28:theme_settings_xxx;........etc...etc...etc....;s:11:custom_logo;i:5810;}

however when I run get_theme_mod( 'my_mod_x' )) nothing comes is returned.

So too when I run on the command line: wp theme mod get --all --allow-root. All I get is:

+--------------------+-------+
| key                | value |
+--------------------+-------+
| custom_css_post_id | 5248  |
+--------------------+-------+

Can anyone tell me what would cause WordPress to think there is only one theme mod when there is supposed to be many?

Topic get-theme-mod migration database Wordpress

Category Web


The problem was that one if the the serialized string lengths did not match its true string length. One of the migration steps was to change the domain name in the database SQL file with:

sed -i 's/old-domain-name/new-domain/g' db-dump.sql

One of the theme mods was a string that contained the old domain name. When it was changed to the new domain name, the length of the string was not adjusted to to match the new string length. Therefore, WordPress was unable to properly read the theme mods.

Lesson: Be careful when doing a global find and replace on the db-dump.sql file!

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.