I'm using wp_remove_get to get the WordPress theme style content (style.css) and then get the theme version number. However I don't know exactly what regex I should use to get the version code:

    $response = wp_remote_get( 'http://example.com/wp-content/themes/theme-name/style.css' );
    if( is_array($response) ) {
        $content = $response['body']; // Remote get the file content. Now get the version number in $content.

Also I'm going to get the version of about 20 themes (sites) on the same page, what I need to do to decrease the page load?


  • What you're doing is inherently expensive/slow, but you should focus on how to do it in this question, and ask follow up questions in new questions once you've got an answer. Of note, regex should be unnecessary, WP already has code to do this in Core
    – Tom J Nowell
    Nov 1, 2015 at 19:16
  • What does "20 themes (sites) on the same page" mean? Is this multisite?
    – s_ha_dum
    Nov 1, 2015 at 20:07
  • It's a theme listing page, no multisite
    – Thomas W.
    Nov 3, 2015 at 1:52

3 Answers 3


Please check out this answer to a similar question about regex for getting info from the theme's style.css.

When it comes to the second part of your question - if you are concerned about page load times, you could always use AJAX to get the information about each theme separately. You would display the page with all themes listed but without their version numbers at first. Once the page is loaded, you could send an AJAX request to wp-admin for each theme, process the information on the backend (get the theme's CSS, run regex to find version number) and formulate a response with the theme's version number. Display the version number on your page and you are done! Repeat for every theme on your list.

  • Seem to solve my question, going to try that but not so good with Ajax. Thanks.
    – Thomas W.
    Nov 3, 2015 at 2:13

You can grab the version number like this:

preg_match('/[\n\r].*Version:\s*([^\n\r]*)/', $content, $matches);
$ver  = $matches[1];
  • It does works but now the main concern is the page load. Thanks
    – Thomas W.
    Nov 3, 2015 at 2:43
  • Page load can be mitigated with asynchronous AJAX requests.
    – Ciprian
    Jun 17, 2019 at 15:16

Do you have control over the theme?

If you do, you can create a file inside your theme, called version.php for example, and add the following code -

header("Access-Control-Allow-Origin: https://www.example.com");

$parse_uri = explode('wp-content', $_SERVER['SCRIPT_FILENAME']);
require $parse_uri[0] . 'wp-load.php';

$currentTheme = wp_get_theme();

echo json_encode($currentTheme->get('Version'));

You can also get the theme name -

echo json_encode($currentTheme->get('Version'));

You can then use PHP or (better) JavaScript to access the version.php on each site and get the theme version. Use promises or async()/await() to get hundreds of themes on the same page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.