如何通过自定义获取WordPress主题名称URL
How to get WordPress theme name by custom URL
我正在尝试使用 API 获取 WordPress 主题名称。我已经尝试过此代码,但我希望使用自定义 url:
获得相同的结果
function theme_list_function(){
// Get a list of themes
$list = wp_get_themes();
// Return the value
var_dump($list);
}
此代码将 return 当前 WordPress 主题列表。我想要 URL 形式的主题列表,例如 xyz.com
我用这段代码实现了这个:
$target_site = ""; // put your wordpress url here
$src = file_get_contents( $target_site );
preg_match("/\<link rel='stylesheet'.*href='(.*?style\.css.*?)'.*\>/i", $src, $matches );
if( $matches ) {
$style_href = trim( $matches[1] );
$style_src = file_get_contents( $style_href );
preg_match( "/\Theme Name:(.*?)\n/i", $style_src, $theme_name );
$theme_name = str_replace(' ', '', $theme_name[1]);
var_dump( $theme_name );
}
我正在尝试使用 API 获取 WordPress 主题名称。我已经尝试过此代码,但我希望使用自定义 url:
获得相同的结果function theme_list_function(){
// Get a list of themes
$list = wp_get_themes();
// Return the value
var_dump($list);
}
此代码将 return 当前 WordPress 主题列表。我想要 URL 形式的主题列表,例如 xyz.com
我用这段代码实现了这个:
$target_site = ""; // put your wordpress url here
$src = file_get_contents( $target_site );
preg_match("/\<link rel='stylesheet'.*href='(.*?style\.css.*?)'.*\>/i", $src, $matches );
if( $matches ) {
$style_href = trim( $matches[1] );
$style_src = file_get_contents( $style_href );
preg_match( "/\Theme Name:(.*?)\n/i", $style_src, $theme_name );
$theme_name = str_replace(' ', '', $theme_name[1]);
var_dump( $theme_name );
}