• I took a number of courses from learn.www.remarpro.com. I thought one of the courses mentioned the ability to get the user values from the database. I’m not sure of the correct term or phrase but by “user values” I mean in the Styles tab there is a double arrow icon with the title of “Set custom size”.

    I finished building a block theme and built my new site using it but I used the Set custom size button many times, mostly for Font-size. I would like to see my manual sizes so that I can go back and edit theme.json. Is there a WordPress function where I can get those vsalues?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi there!

    Yes, you can retrieve custom values set in the block editor, especially those from the Styles tab (such as custom font sizes) that were manually applied via the “Set custom size” option.

    Custom values set via the Styles tab are stored in the wp_global_styles table in your WordPress database. This table holds the site-wide global styles, including any customizations you make via the Site Editor (Appearance → Editor).

    You can access these values using the wp_get_global_styles() function in PHP. This will return an array of all global styles applied to your theme. If you want to specifically extract font sizes, you can do something like this:

    $global_styles = wp_get_global_styles();
    $font_sizes = $global_styles['typography']['fontSize'] ?? null;

    Alternatively, you can check the wp_global_styles table in your database using phpMyAdmin. Look for a record related to your theme and inspect the JSON-stored values inside.

    If you want to adjust your theme.json to match the sizes you manually set, you can:

    • Copy the values from the wp_global_styles table.
    • Manually update theme.json with those values under the "styles" section.
    • Reset the global styles in the Site Editor to ensure your theme.json settings take effect.

    Let me know if you need more details.

    Thread Starter Jim

    (@kernix)

    Excellent – thanks! I know I read about this somewhere but I can’t find it in my notes. A few things though:

    • I think the only changes I made in the Site Editor was for the background-color for buttons. The changes I want are from the block editor while building my pages.
    • So now I know where to look in the database, but that could be time consuming. Will wp_get_global_styles() it return those values, or will that only get changes in the Site editor? And how did you know to use ['typography']['fontSize']? I looked in the reference docs for the function, and they do not show the options I can pull from the results.
    • If wp_get_global_styles() does not get the custom sizes set in the block editor, what would get that for me?

    Can the results be sent to a log file or should I just echo the results?

    Thread Starter Jim

    (@kernix)

    Any chance I can get a reply? Do I use var_dump? Where do I run the PHP?

    Thread Starter Jim

    (@kernix)

    Ok, I created a function in functions.php and used var_dump:

    function get_custom_values() {
    $global_styles = wp_get_global_styles();
    $font_sizes = $global_styles['typography']['fontSize'] ?? null;

    var_dump($font_sizes);

    }
    add_action('init', 'get_custom_values', 9999);

    And this is what I get: string(36) "var(--wp--preset--font-size--medium)"

    How do I interpret that? Does the 36 mean that there are 36 occurrences of the medium size being changed? How can I see each of the 36? I think I set them to a smaller value but I would like to see the values.

    And does that mean that the medium font size is the only one that was changed?

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.